Submission #77140

#TimeUsernameProblemLanguageResultExecution timeMemory
77140dooweyAliens (IOI07_aliens)C++14
100 / 100
5 ms548 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int N, M, x, y, i, d, a, lo, hi; string inp; bool get(int x,int y){ printf("examine %d %d\n",(signed)x,(signed)y); fflush(stdout); cin >> inp; return inp == "true"; } signed main(){ scanf("%lld%lld%lld",&N,&x,&y); for(i=0;x+(1LL<<i)<=N;i++){ if(!get(x+(1LL<<i),y)) break; } lo = 1, hi = 1LL<<i; while(lo<hi){ int m=lo+hi>>1; if(!get(x+m,y)) hi=m; else lo=m+1; } lo--; d = lo; a = 0; for(i=0;x-(1LL<<i)>=1;i++){ if(!get(x-(1LL<<i),y)) break; } lo = 1, hi = 1LL<<i; while(lo<hi){ int m=lo+hi>>1; if(!get(x-m,y)) hi=m; else lo=m+1; } lo--; M = 1+lo+d; a=0; x += (M/2)-lo; for(i=0;y+(1LL<<i)<=N;i++){ if(!get(x,y+(1LL<<i))) break; } lo = 1, hi = 1LL<<i; while(lo<hi){ int m=lo+hi>>1; if(!get(x,y+m)) hi=m; else lo=m+1; } lo--; y -= (M/2)-lo; int l=0, r=0, u=0, d=0; for(i=1;2*M*i+x<=N;i++){ if(!get(x+2*M*i,y)) break; } r = i-1; for(i=1;x-2*M*i>=1;i++){ if(!get(x-2*M*i,y)) break; } l = i-1; for(i=1;y+2*M*i<=N;i++){ if(!get(x,y+2*M*i)) break; } u = i-1; for(i=1;y-2*M*i>=1;i++){ if(!get(x,y-2*M*i)) break; } d = i-1; if(l+r==1){ if(!r) x -= M; else x += M; if(!u) y -= M; else y += M; } else{ x += 2*M*(r-1); y += 2*M*(u-1); } printf("solution %d %d\n",(signed)x,(signed)y); fflush(stdout); return 0; }//19 5 16

Compilation message (stderr)

aliens.cpp: In function 'int main()':
aliens.cpp:20:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
       int m=lo+hi>>1;
             ~~^~~
aliens.cpp:30:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
       int m=lo+hi>>1;
             ~~^~~
aliens.cpp:41:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
       int m=lo+hi>>1;
             ~~^~~
aliens.cpp:46:25: warning: variable 'd' set but not used [-Wunused-but-set-variable]
      int l=0, r=0, u=0, d=0;
                         ^
aliens.cpp:14:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%lld%lld%lld",&N,&x,&y);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...