Submission #632203

#TimeUsernameProblemLanguageResultExecution timeMemory
632203PoonYaPatAliens (IOI07_aliens)C++14
0 / 100
2 ms208 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n,x,y;
ll bn,bs,be,bw;
int cnt;

bool examine(ll x, ll y) {
    if (x<1 || y<1 || x>n || y>n) return false;
    cout<<"examine "<<x<<" "<<y<<endl;
    string s;
    cin>>s;
    if (s=="true") return true;
    else return false;
}

int main() {
    cin>>n>>x>>y;

    //east
    ll k=1;
    while (examine(x+k,y)) k*=2,cnt++;
    ll l=x, r=min(n,x+k);

    while (r>=l) {
        ll mid=(l+r)/2;
        if (examine(mid,y)) l=mid+1;
        else r=mid-1;
    }
    be=r;

    //north
    k=1;
    while (examine(x,y+k)) k*=2;
    l=y; r=min(n,y+k);
    while (r>=l) {
        ll mid=(l+r)/2;
        if (examine(x,mid)) l=mid+1;
        else r=mid-1;
    }
    bn=r;

    //west
    k=1;
    while (examine(x-k,y)) k*=2;
    l=max(1ll,x-k); r=x;
    while (r>=l) {
        int mid=(l+r)/2;
        if (examine(mid,y)) r=mid-1;
        else l=mid+1;
    }
    bw=l;

    //south
    k=1;
    while (examine(x,y-k)) k*=2;
    l=y; r=max(1ll,y-k);
    while (r>=l) {
        int mid=(l+r)/2;
        if (examine(x,mid)) r=mid-1;
        else l=mid+1;
    }
    bs=l;

    ll cx=(be+bw)/2, cy=(bn+bs)/2, sz=(be-bw+1)*2;
    ll E,W,N,S;

    ll x=cx, y=cy;
    while (examine(x,y)) x+=sz;
    E=x-sz; x=cx; y=cy;
    while (examine(x,y)) x-=sz;
    W=x+sz; x=cx; y=cy;
    while (examine(x,y)) y+=sz;
    S=y-sz; x=cx; y=cy;
    while (examine(x,y)) y-=sz;
    N=y+sz; x=cx; y=cy;

    cout<<"solution "<<(E+W)/2<<" "<<(N+S)/2<<flush;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...