#include "minecraft.h"
#include <bits/stdc++.h>
using namespace std;
int n,k;
vector <int> v;
int dnc(int l,int r,int val)
{
    if(val==0)return val;
    if(l==r)
    {
        v.push_back(l);
        return val;
    }
    int mid=(l+r)/2;
    int v=val;
    val-=dnc(l,mid,find_portals(l,mid));
    val-=dnc(mid+1,r,val);
    return v;
}
std::vector<int> portals(int N, int K)
{
    n=N;
    k=K;
    dnc(1,N,k);
    return v;
}

std::pair<int, int> minimal_danger(int N, std::vector<std::pair<int, std::pair<int, int>>> paths, std::vector<int> portals, std::vector<int> fortresses) {
    return {0, 0};
}

std::pair<int, int> find_end_portal(int L)
{
    int l1=1,r1=L,l2=1,r2=L;
    while(l1<=r1&&l2<=r2)
    {
        int mid1=(l1+r1)/2,mid2=(l2+r2)/2;
        string t=throw_eye({mid1,mid2});
        if(t=="NONE")
        {
            return {mid1,mid2};
        }
        if(t.find('N')!=-1)l1=mid1+1;
        else if(t.find('S')!=-1)r1=mid1-1;
        if(t.find('W')!=-1)l2=mid2+1;
        else if(t.find('E')!=-1)r2=mid2-1;
    }
    return {l1,l2};
}
