Submission #1091238

#TimeUsernameProblemLanguageResultExecution timeMemory
1091238why_5_minsColors (BOI20_colors)C++14
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n; int getx() { int st = 0, pas = 1ll << 60; while (pas != 0) { if (st + pas <= n) { int x = st + pas; bool oops = false; int l = 1, r = n, pass = -1; while (l < r) { int y; pass++; int rn = (r - l) / 2; if (pass % 2 == 0) y = x + l + rn; else y = x - l - rn; if (y > n) oops = true; l = abs(x - y) + 1; x = y; } if (!oops) st += pas; } pas /= 2; } return st; } signed main() { cin >> n; int x = getx(); cout << "? " << x << endl; int rsp; cin >> rsp; int l = 1, r = n; int pas = -1; while (l < r) { int y; pas++; ///eu legit caut binar cu l si r, in ce hal am ajuns int rn = (r - l) / 2; if (pas % 2 == 0) y = x + l + rn; else y = x - l - rn; y = max(y, 0ll); y = min(y, n); cout << "? " << y << endl; if (y <= 0) assert(false); if (y > n) while(true); cin >> rsp; if (rsp == 0) l = abs(x - y) + 1; else r = abs(x - y); x = y; } cout << l; 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...