Submission #759522

#TimeUsernameProblemLanguageResultExecution timeMemory
759522gun_ganAliens (IOI07_aliens)C++17
10 / 100
2 ms464 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; ll N, X, Y; ll xMin, xMax, yMin, yMax; bool can(ll x, ll y) { if(x <= 0 || x > N || y <= 0 || y > N) return 0; cout << "examine " << x << " " << y << endl; string s; cin >> s; return s == "true"; } void work(int k) { ll l = 0, r = 1e9, res = 0; while(l <= r) { ll m = (l + r) >> 1; if(can(X + 2 * m * dx[k], Y + 2 * m * dy[k])) { l = m + 1, res = m; } else { r = m - 1; } } xMin = min(xMin, X + 2 * res * dx[k]); xMax = max(xMax, X + 2 * res * dx[k]); yMin = min(yMin, Y + 2 * res * dy[k]); yMax = max(yMax, Y + 2 * res * dy[k]); } int main() { // ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> X >> Y; xMin = xMax = X; yMin = yMax = Y; for(int k = 0; k < 4; k++) work(k); assert(xMax - xMin == yMax - yMin && (xMax - xMin + 1) & 1); // cout << xMin << " " << yMin << endl; // cout << xMax << " " << yMax << endl; int decx = 0, decy = 0, incx = 0, incy = 0; if(can(xMin - 1, yMin - 1)) { decx = 1; decy = 1; } if(can(xMin + 1, yMin - 1)) { if(xMin == xMax) incx = 1; decy = 1; } if(can(xMin - 1, yMin + 1)) { decx = 1; if(yMin == yMax) incy = 1; } if(can(xMin - 1, yMax + 1)) { decx = 1; incy = 1; } if(can(xMin + 1, yMax + 1)) { if(xMin == xMax) incx = 1; incy = 1; } if(can(xMin - 1, yMax - 1)) { decx = 1; if(yMin == yMax) decy = 1; } if(can(xMax + 1, yMin - 1)) { incx = 1; decy = 1; } if(can(xMax - 1, yMin - 1)) { if(xMin == xMax) decx = 1; decy = 1; } if(can(xMax + 1, yMin + 1)) { incx = 1; if(yMin == yMax) incy = 1; } if(can(xMax + 1, yMax + 1)) { incx = 1; incy = 1; } if(can(xMax - 1, yMax + 1)) { if(xMin == xMax) decx = 1; incy = 1; } if(can(xMax + 1, yMax - 1)) { incx = 1; if(yMin == yMax) decy = 1; } xMin -= decx; yMin -= decy; xMax += incx; yMax += incy; cout << "solution " << (xMin + xMax) / 2 << " " << (yMin + yMax) / 2 << endl; }
#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...