Submission #337629

#TimeUsernameProblemLanguageResultExecution timeMemory
337629blueAliens (IOI07_aliens)C++11
100 / 100
2 ms372 KiB
#include <iostream> #include <string> #include <algorithm> using namespace std; /* Searching for x0+1, x0+2, x0+4, x0+8... and the same y=y0, and then performing a binary search, we can find the right edge of the flattened square containing x0, in 30+30=60 queries. The binary search cannot return a false positive because the flattened squares are separated by non-flattened squares. Also, the left edge in 60 queries. Also, the bottom edge in 60 queries. Using the side length and bottom edge, we already know the top edge. Using 2 queries for left and right, and 2 queries for top and bottom, we can figure out which flattened square we are currently in. This information should be sufficient to locate the center. */ long long N, X0, Y0; //side of meadow, coordinates of one flattened square. int query(long long x, long long y) { if(x < 1 || N < x) return 0; if(y < 1 || N < y) return 0; cout << "examine " << x << ' ' << y << '\n'; string s; cin >> s; return (s == "true"); } void solve(long long x, long long y) { cout << "solution " << x << ' ' << y << '\n'; } int main() { cin >> N >> X0 >> Y0; long long l_edge, r_edge, b_edge, t_edge; long long a, b, m; //----------------------------------------------- // cout << "part 1\n"; a = X0; for(b = X0+1; b <= N; b += (b - X0)) { if(query(b, Y0)) a = b; else break; } b = min(b-1, N); while(a != b) { m = (a+b)/2+1; if(query(m, Y0)) a = m; else b = m-1; } b_edge = a; //----------------------------------------------- // cout << "part 2\n"; a = Y0; for(b = Y0+1; b <= N; b += (b - Y0)) { if(query(X0, b)) a = b; else break; } b = min(b-1, N); while(a != b) { m = (a+b)/2+1; if(query(X0, m)) a = m; else b = m-1; } r_edge = a; //----------------------------------------------- // cout << "part 3\n"; b = Y0; for(a = Y0-1; a >= 1; a -= (Y0 - a)) { // cout << a << ' ' << query(X0, a) << '\n'; if(query(X0, a)) b = a; else break; } a = max(a+1, 1LL); // cout << a << '\n'; while(a != b) { // cout << a << ' ' << b << '\n'; m = (a+b)/2; if(query(X0, m)) b = m; else a = m+1; } // cout << a << '\n'; l_edge = b; //----------------------------------------------- int s = r_edge - (l_edge - 1); // cout << s << '\n'; t_edge = b_edge - s + 1; // cout << t_edge << ' ' << b_edge << ' ' << l_edge << ' ' << r_edge << '\n'; int cx = (t_edge + b_edge)/2; int cy = (l_edge + r_edge)/2; int res_x = cx, res_y = cy; if(query(cx, cy + 4*s)) res_y = cy + 2*s; else if(query(cx, cy + 2*s) && !query(cx, cy - 2*s)) res_y = cy + s; else if(query(cx, cy - 4*s)) res_y = cy - 2*s; else if(query(cx, cy - 2*s) && !query(cx, cy + 2*s)) res_y = cy - s; if(query(cx + 4*s, cy)) res_x = cx + 2*s; else if(query(cx + 2*s, cy) && !query(cx - 2*s, cy)) res_x = cx + s; else if(query(cx - 4*s, cy)) res_x = cx - 2*s; else if(query(cx - 2*s, cy) && !query(cx + 2*s, cy)) res_x = cx - s; solve(res_x, res_y); }
#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...