Submission #167066

#TimeUsernameProblemLanguageResultExecution timeMemory
167066beso123Aliens (IOI07_aliens)C++14
80 / 100
4 ms420 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int n; int q=0; bool ask(int x,int y){ if(x<=0 || y<=0 || x>n || y>n) return false; q++; if(q==299){ int x=1/0; cout<<1/0; } cout<<"examine"<<' '<<x<<' '<<y<<endl; string s; cin>>s; if(s=="true") return true; return false; } int x,y; main(){ cin>>n>>x>>y; int xr=0; int log=1; int l=0,r=0; while(true){ if(x+log>n){ l=x+(log/2); r=n; break; } if(!ask(x+log,y)){ r=x+log; l=x+(log/2); break; } log*=2; } while(r-l>1){ int mid=(l+r)/2; if(ask(mid,y)) l=mid; else r=mid; } if(ask(r,y)) xr=r; else xr=l; int xl=0; log=1; l=0; r=0; while(true){ if(x-log<=0){ l=1; r=x-(log/2); break; } if(!ask(x-log,y)){ l=x-log; r=x-(log/2); break; } log*=2; } while(r-l>1){ int mid=(l+r)/2; if(ask(mid,y)) r=mid; else l=mid; } if(ask(l,y)) xl=l; else xl=r; int yn=0; log=1; l=0; r=0; while(true){ if(y+log>n){ l=y+(log/2); r=n;while(true){ if(x+log>n){ l=x+(log/2); r=n; break; } if(!ask(x+log,y)){ r=x+log; l=x+(log/2); break; } log*=2; } while(r-l>1){ int mid=(l+r)/2; if(ask(mid,y)) l=mid; else r=mid; } if(ask(r,y)) xr=r; else xr=l; break; } if(!ask(x,log+y)){ r=y+log; l=y+(log/2); break; } log*=2; } while(r-l>1){ int mid=(l+r)/2; if(ask(x,mid)) l=mid; else r=mid; } if(ask(x,r)) yn=r; else yn=l; int p=1; int m=xr-xl+1; int x=(xr+xl)/2; int y=yn-(m/2); int ax=0,ay=0; int ind1=0,ind2=0; if(y+2*m<=n && ask(x,y+2*m)){ ind1=1; p++; } if(y+4*m<=n && ask(x,y+4*m)){ p++; } if(y-2*m>=1 && ask(x,y-2*m)){ p++; } if(y-4*m>=1 && ask(x,y-4*m)){ p++; } if(p!=3){ x-=m; y-=m; ind1=1; } if(y+4*m<=n && ask(x,y+4*m)){ ind2=1; } if(ind2==1){ ay=y+2*m; } else{ if(ind1==1) ay=y; else{ ay=y-2*m; } } ind1=0,ind2=0; if(x+2*m<=n && ask(x+2*m,y)) ind1=1; if(x+4*m<=n && ask(x+4*m,y)) ind2=1; if(ind2==1){ ax=x+2*m; } else{ if(ind1==1) ax=x; else{ ax=x-2*m; } } cout<<"solution"<<' '<<ax<<' '<<ay<<endl; return 0; }

Compilation message (stderr)

aliens.cpp: In function 'bool ask(long long int, long long int)':
aliens.cpp:7:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(x<=0 || y<=0 || x>n || y>n)
     ^~
aliens.cpp:9:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         q++;
         ^
aliens.cpp:11:20: warning: division by zero [-Wdiv-by-zero]
             int x=1/0;
                   ~^~
aliens.cpp:12:20: warning: division by zero [-Wdiv-by-zero]
             cout<<1/0;
                   ~^~
aliens.cpp:11:17: warning: unused variable 'x' [-Wunused-variable]
             int x=1/0;
                 ^
aliens.cpp:18:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(s=="true")
     ^~
aliens.cpp:20:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         return false;
         ^~~~~~
aliens.cpp: At global scope:
aliens.cpp:23:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#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...