Submission #597176

#TimeUsernameProblemLanguageResultExecution timeMemory
597176flappybirdColors (BOI20_colors)C++17
0 / 100
1 ms316 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,fma") using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define MAX 201010 #define MAXS 20 #define INF 1000000000000000001 #define bb ' ' #define ln '\n' #define Ln '\n' int query(ll x) { cout << "? " << x << endl; int a; cin >> a; return a; } signed main() { ios::sync_with_stdio(false), cin.tie(0); ll N; cin >> N; ll l, r; l = 1, r = N; vector<ll> big; ll dir = 1; while (1) { ll mid = (l + r) / 2; l = mid + 1; big.push_back(mid); if (mid == r - 1) break; } reverse(big.begin(), big.end()); ll st = 1; for (auto v : big) st += v * dir, dir *= -1; l = 1; r = N; query(st); int str = 1; while (l < r) { ll mid = (l + r) / 2; int res = query(st + dir * mid); st += dir * mid; dir *= -1; if (res) { r = mid; if (str) { query(N - r); str = 0; dir = 1; st = N - r; } } else l = mid + 1; } cout << "! " << 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...