제출 #645414

#제출 시각아이디문제언어결과실행 시간메모리
645414gun_ganAliens (IOI07_aliens)C++17
10 / 100
3 ms208 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int dx[4] = {1, -1, -1, 1}, dy[4] = {-1, -1, 1, 1}; int n, X_[2], Y_[2]; bool ask(int x, int y) { if(x <= 0 || y <= 0 || x > n || y > n) return 0; cout << "examine " << x << " " << y << endl; string s; cin >> s; return s == "true"; } void work(int x, int y) { // cout << x << " " << y << endl; int x1 = 0, x2 = 0, y1 = 0, y2 = 0; { int l = 0, r = n; while(l <= r) { int mid = (l + r) / 2; if(ask(x, y + 2 * mid)) { l = mid + 1, y2 = mid; } else { r = mid - 1; } } } { int l = 0, r = n; while(l <= r) { int mid = (l + r) / 2; if(ask(x, y - 2 * mid)) { l = mid + 1, y1 = mid; } else { r = mid - 1; } } } { int l = 0, r = n; while(l <= r) { int mid = (l + r) / 2; if(ask(x - 2 * mid, y)) { l = mid + 1, x1 = mid; } else { r = mid - 1; } } } { int l = 0, r = n; while(l <= r) { int mid = (l + r) / 2; if(ask(x + 2 * mid, y)) { l = mid + 1, x2 = mid; } else { r = mid - 1; } } } X_[0] = min(X_[0], x - 2 * x1); Y_[0] = min(Y_[0], y - 2 * y1); X_[1] = max(X_[1], x + 2 * x2); Y_[1] = max(Y_[1], y + 2 * y2); // cout << X_[0] << " " << Y_[0] << " " << X_[1] << " " << Y_[1] << endl; } signed main() { cin.tie(0); ios_base::sync_with_stdio(0); int x, y; cin >> n >> x >> y; X_[0] = 1e18, Y_[0] = 1e18; work(x, y); int X = 0, Y = 0; for(int i = 0; i < 4; i++) { if(ask(x + dx[i], y + dy[i])) { X = x + dx[i], Y = y + dy[i]; break; } } // cout << X << " " << Y << '\n'; work(X, Y); // cout << X_[0] << " " << X_[1] << '\n'; cout << "solution " << (X_[0] + X_[1]) / 2 << " " << (Y_[0] + Y_[1]) / 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...