Submission #1057841

#TimeUsernameProblemLanguageResultExecution timeMemory
105784112345678Aliens (IOI07_aliens)C++17
10 / 100
1 ms440 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int kx=32; ll n, a, b, p[kx], mnx, mny, mxx, mxy, tmp, cx, cy, sz, tmnx, tmxx, tmny, tmxy; map<pair<ll, ll>, int> mp; string res; int query(ll x, ll y) { if (x<1||x>n||y<1||y>n) return 0; if (mp.find({x, y})!=mp.end()) return mp[{x, y}]; cout<<"examine "<<x<<' '<<y<<endl; fflush(stdout); cin>>res; return mp[{x, y}]=(res[0]=='t'); } int main() { cin>>n>>a>>b; p[0]=1; for (int i=1; i<kx; i++) p[i]=p[i-1]*2; mnx=mxx=a, mny=mxy=b; for (int i=kx-1; i>=0; i--) if (query(mnx-p[i], b)) mnx=mnx-p[i]; for (int i=kx-1; i>=0; i--) if (query(mxx+p[i], b)) mxx=mxx+p[i]; for (int i=kx-1; i>=0; i--) if (query(a, mny-p[i])) mny=mny-p[i]; for (int i=kx-1; i>=0; i--) if (query(a, mxy+p[i])) mxy=mxy+p[i]; tmnx=tmxx=cx=(mnx+mxx)/2; tmny=tmxy=cy=(mny+mxy)/2; sz=mxx-mnx+1; for (int i=1; i<=2; i++) if (query(cx-i*sz, cy)) tmnx=min(tmnx, cx-i*sz); for (int i=1; i<=2; i++) if (query(cx+i*sz, cy)) tmxx=max(tmxx, cx+i*sz); for (int i=1; i<=2; i++) if (query(cx, cy-i*sz)) tmny=min(tmny, cy-i*sz); for (int i=1; i<=2; i++) if (query(cx, cy+i*sz)) tmxy=min(tmxy, cy+i*sz); cout<<"solution "<<(tmnx+tmxx)/2<<' '<<(tmny+tmxy)/2<<endl; fflush(stdout); }
#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...