Submission #502095

#TimeUsernameProblemLanguageResultExecution timeMemory
502095tabrAliens (IOI07_aliens)C++17
100 / 100
2 ms200 KiB
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, x0, y0; cin >> n >> x0 >> y0; x0--, y0--; auto ask = [&](long long x, long long y) { if (max(x, y) >= n || min(x, y) < 0) { return false; } cout << "examine " << x + 1 << " " << y + 1 << endl; string s; cin >> s; return (s == "true"); }; long long r; { long long t = 2; while (ask(x0 + t - 1, y0)) { t <<= 1; } long long lo = x0; long long hi = x0 + t - 1; while (hi - lo > 1) { long long mid = (hi + lo) / 2; if (ask(mid, y0)) { lo = mid; } else { hi = mid; } } r = lo; } long long l; { long long t = 2; while (ask(x0 - t + 1, y0)) { t <<= 1; } long long lo = x0 - t + 1; long long hi = x0; while (hi - lo > 1) { long long mid = (hi + lo) / 2; if (ask(mid, y0)) { hi = mid; } else { lo = mid; } } l = hi; } x0 = (l + r) / 2; long long m = r - l + 1; { long long lo = y0; long long hi = y0 + m; while (hi - lo > 1) { long long mid = (hi + lo) / 2; if (ask(x0, mid)) { lo = mid; } else { hi = mid; } } y0 = lo - m / 2; } if (ask(x0 + 4 * m, y0)) { x0 += 2 * m; } else if (ask(x0 - 4 * m, y0)) { x0 -= 2 * m; } else { int a = ask(x0 + 2 * m, y0); int b = ask(x0 - 2 * m, y0); if (a && !b) { x0 += m; } else if (!a && b) { x0 -= m; } } if (ask(x0, y0 + 3 * m)) { y0 += m; } else if (ask(x0, y0 - 3 * m)) { y0 -= m; } else { int a = ask(x0, y0 + 2 * m); int b = ask(x0, y0 - 2 * m); if (a && !b) { y0 += 2 * m; } else if (!a && b) { y0 -= 2 * m; } } cout << "solution " << x0 + 1 << " " << y0 + 1 << 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...