제출 #680506

#제출 시각아이디문제언어결과실행 시간메모리
680506jhwest2Colors (BOI20_colors)C++17
0 / 100
0 ms208 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n; bool debug = 1; int last = 0, C = 1; bool ask(ll x) { assert(1 <= x && x <= n); bool res; cout << "? " << x << endl; if (debug) { if (abs(last - x) >= C) res = 1; else res = 0; last = x; cout << res << endl; } else cin >> res; return res; } int main() { cin >> n; // finding the starting position ll L = 1, R = n, x = 0, dir = 0; ll minv = 0, maxv = 0; while (L < R) { ll M = (L + R) / 2; if (dir == 0) { x += M; maxv = max(maxv, x); } else { x -= M; minv = min(minv, x); } dir = 1 - dir; L = M + 1; } assert(maxv - minv <= n - 1); L = 1; R = n; x = 1 - minv; dir = 0; ask(x); while (L < R) { ll M = (L + R) / 2; bool r; if (dir == 0) { r = ask(x + M); x += M; } else { r = ask(x - M); x -= M; } dir = 1 - dir; if (r) R = M; else L = M + 1; } cout << "= " << L << 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...