Submission #572751

#TimeUsernameProblemLanguageResultExecution timeMemory
572751snasibov05Aliens (IOI07_aliens)C++14
80 / 100
4 ms336 KiB
#include <bits/stdc++.h> using namespace std; bool ask(int x, int y){ cout << "examine " << x << " " << y << endl; string str; cin >> str; if (str == "true") return true; else return false; } int main() { int n, x0, y0; cin >> n >> x0 >> y0; int xt = x0, yt = y0, xb = x0; int x = 1; while (xt - x >= 1 && ask(xt - x, y0)) xt -= x, x *= 2; int l = xt - x, r = xt; while (l <= r){ int mid = (l + r) / 2; if (mid >= 1 && ask(mid, y0)) xt = mid, r = mid - 1; else l = mid + 1; } x = 1; while (xb + x <= n && ask(xb + x, y0)) xb += x, x *= 2; l = xb, r = xb + x; while (l <= r){ int mid = (l + r) / 2; if (mid <= n && ask(mid, y0)) xb = mid, l = mid + 1; else r = mid - 1; } x = 1; while (yt - x >= 1 && ask(x0, yt - x)) yt -= x, x *= 2; l = yt - x, r = yt; while (l <= r){ int mid = (l + r) / 2; if (mid >= 1 && ask(x0, mid)) yt = mid, r = mid - 1; else l = mid + 1; } int sz = xb - xt + 1; while (xt - 2*sz >= 1 && ask(xt - 2*sz, yt)) xt = xt - 2*sz; while (true){ if (xt - sz >= 1 && yt - sz >= 1 && ask(xt - sz, yt - sz)) xt = xt - sz, yt = yt - sz; else if (xt + sz <= n && yt - sz >= 1 && ask(xt + sz, yt - sz)) xt = xt + sz, yt = yt - sz; else break; } int xres = xt + 2*sz + sz / 2; int yres = yt + 2*sz + sz / 2; cout << "solution " << xres << " " << yres << 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...