Submission #112752

#TimeUsernameProblemLanguageResultExecution timeMemory
112752IVIosabAliens (IOI07_aliens)C++17
60 / 100
3041 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second int n,nx,ny; int findright(){ int x=nx,y=ny; int cnt=1; int l=0,r=0; while(true){ string in; if(x+cnt<=n) { cout << "examine " << x + cnt << " " << y << endl; cin >> in; } else{ r=n; l=x+(cnt/2); break; } if(in!="true"){ l=x+(cnt/2); r=x+cnt; break; } else { cnt *= 2; } } while(l<=r){ int mid=(l+r)/2; cout<<"examine "<<mid<<" "<<y<<endl; string st; cin>>st; if(st=="true"){ l=mid+1; } else{ r=mid-1; } } return l-1; } int findleft(){ int x=nx,y=ny; int cnt=1; int l=0,r=0; while(true){ string in; if(x-cnt>=1) { cout << "examine " << x - cnt << " " << y << endl; cin >> in; } else{ l=1; r=x-(cnt/2); break; } if(in!="true"){ l=x-cnt; r=x-(cnt/2); break; } else { cnt *= 2; } } while(l<=r){ int mid=(l+r)/2; cout<<"examine "<<mid<<" "<<y<<endl; string st; cin>>st; if(st=="true"){ r=mid-1; } else{ l=mid+1; } } return r+1; } int findbottom(){ int x=nx,y=ny; int cnt=1; int l=0,r=0; while(true){ string in; if(y-cnt>=1) { cout << "examine " << x << " " << y - cnt << endl; cin >> in; } else{ l=1; r=y-(cnt/2); } if(in!="true"){ l=y-cnt; r=y-(cnt/2); break; } else { cnt *= 2; } } while(l<=r){ int mid=(l+r)/2; cout<<"examine "<<x<<" "<<mid<<endl; string st; cin>>st; if(st=="true"){ r=mid-1; } else{ l=mid+1; } } return r+1; } int main() { //freopen("sample-8.in", "r", stdin); //freopen("output8.txt", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>nx>>ny; int r=findright(),l=findleft(),b=findbottom(); int m=r-l+1; int resx=l+(m/2),resy=b+(m/2); string sr; m*=2; bool _1=false,_2=false,_3=false,_4=false; if(resx-m>=1) { cout << "examine " << resx - m << " " << resy << endl; cin >> sr; if (sr == "false") { resx += m; _1=true; } } else{ resx += m; _1=true; } if(resx+m<=n) { cout << "examine " << resx + m << " " << resy << endl; cin >> sr; if (sr == "false") { resx -= m; _2=true; } } else{ resx-=m; _2=true; } if(resy-m>=1) { cout << "examine " << resx << " " << resy - m << endl; cin >> sr; if (sr == "false") { resy += m; _3=true; } } else{ resy+=m; _3=true; } if(resy-m<=n) { cout << "examine " << resx << " " << resy + m << endl; cin >> sr; if (sr == "false") { resy -= m; _4=true; } } else{ resy-=m; _4=true; } if((_1&&_2)||(_3&&_4)){ m/=2; resx+=m; resy+=m; } cout<<"solution "<<resx<<" "<<resy<<endl; return 0; }
#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...