Submission #370965

#TimeUsernameProblemLanguageResultExecution timeMemory
370965flappybirdColors (BOI20_colors)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define MAX 101010 #define ln '\n' #define bb ' ' #define abs(x) ((x)>0?(x):-(x)) ll query(ll x) { cout << '?' << bb << x << endl; ll ret; cin >> ret; return ret; } signed main() { ll N; cin >> N; ll l, r, mid; l = 0, r = N; ll prev = N / 2; query(prev); ll res; while (r - l > 1) { mid = (l + r + 1) >> 1; if (1 <= prev + mid && prev + mid <= N && 1 <= prev - mid && prev - mid <= N) { ll a = min(abs(prev + mid - 1), abs(prev + mid - N)); ll b = min(abs(prev - mid - 1), abs(prev - mid - N)); if (a < b) { prev += mid; res = query(prev); } else { prev -= mid; res = query(prev); } } else if (1 <= prev + mid && prev + mid <= N) { prev += mid; res = query(prev); } else if (1 <= prev - mid && prev - mid <= N) { prev -= mid; res = query(prev); } else { query(1); res = query(mid + 1); } if (res) r = mid; else l = mid; } cout << '=' << bb << r << 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...