Submission #1178878

#TimeUsernameProblemLanguageResultExecution timeMemory
1178878amongus_pvpAliens (IOI07_aliens)C++17
0 / 100
0 ms408 KiB
#include <iostream> #include <string> #include <algorithm> using namespace std; int N, X0, Y0; bool examine(int x, int y) { cout << "examine " << x << " " << y << endl; string response; cin >> response; return response == "true"; } int findLeft(int x, int y) { int low = 1, high = x, left = x; while (low <= high) { int mid = (low + high) / 2; if (examine(mid, y)) { left = mid; high = mid - 1; } else { low = mid + 1; } } return left; } int findRight(int x, int y) { int low = x, high = N, right = x; while (low <= high) { int mid = (low + high) / 2; if (examine(mid, y)) { right = mid; low = mid + 1; } else { high = mid - 1; } } return right; } int findBottom(int x, int y) { int low = 1, high = y, bottom = y; while (low <= high) { int mid = (low + high) / 2; if (examine(x, mid)) { bottom = mid; high = mid - 1; } else { low = mid + 1; } } return bottom; } int findTop(int x, int y) { int low = y, high = N, top = y; while (low <= high) { int mid = (low + high) / 2; if (examine(x, mid)) { top = mid; low = mid + 1; } else { high = mid - 1; } } return top; } int main() { cin >> N >> X0 >> Y0; int left = findLeft(X0, Y0); int right = findRight(X0, Y0); int Mx = right - left + 1; int bottom = findBottom(X0, Y0); int top = findTop(X0, Y0); int My = top - bottom + 1; int M = Mx; // Assuming Mx == My // Find the top-left corner of the entire 5x5 chessboard int chessLeft = left; while (chessLeft - M >= 1 && examine(chessLeft - M, Y0)) { chessLeft -= M; } int chessBottom = bottom; while (chessBottom - M >= 1 && examine(X0, chessBottom - M)) { chessBottom -= M; } // The center of the chessboard is at (chessLeft + 2*M, chessBottom + 2*M) int XC = chessLeft + 2 * M; int YC = chessBottom + 2 * M; cout << "solution " << XC << " " << YC << 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...