Submission #723784

#TimeUsernameProblemLanguageResultExecution timeMemory
723784JohannColors (BOI20_colors)C++14
0 / 100
1 ms312 KiB
#include "bits/stdc++.h" using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; #define sz(x) (int)(x).size() vi queries; vi ans; int query(int i) { queries.push_back(i); cout << "? " << i << endl; int a; cin >> a; ans.push_back(a); return a; } void answer(int i) { cout << "= " << i << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int N; cin >> N; int l = 1, r = N; while (r - l > 60) l += 30, r -= 30; if (r - l > 30) l += 30; double center = (l + r) / (double)2; int len = r - l; int a = 0; query(l); a = query(r); while (a == 0 && len < N - 1) { len += 30; int last = queries.back(); int next = last; if (last < center) next += len; else next -= len; a = query(next); } if (a == 0) answer(N); else { int lowerB = max(1, len - 30); while (a == 1 && len > lowerB) { len -= 1; int last = queries.back(); int next = last; if (last < center) next += len; else next -= len; a = query(next); } if (a == 0) answer(len + 1); else answer(len); } 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...