Submission #546002

#TimeUsernameProblemLanguageResultExecution timeMemory
546002skittles1412Colors (BOI20_colors)C++17
67 / 100
3 ms592 KiB
#include "bits/extc++.h" using namespace std; template <typename T> void dbgh(const T& t) { cerr << t << endl; } template <typename T, typename... U> void dbgh(const T& t, const U&... u) { cerr << t << " | "; dbgh(u...); } #ifdef DEBUG #define dbg(...) \ cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \ << ": "; \ dbgh(__VA_ARGS__) #else #define cerr \ if (false) \ cerr #define dbg(...) #endif #define endl "\n" #define long int64_t #define sz(x) int((x).size()) // 0 = x > query // 1 = x <= query int n; int search(int l, int r, bool add) { if (l == r) { if (add) { return 1; } else { return n; } } int mid = (l + r - 1) / 2; int nxt = search(mid + 1, r, !add); if (add) { return nxt - mid; } else { return nxt + mid; } } void solve(int l, int r, int prev, bool add) { static set<int> vis; if (l == r) { cout << "= " << l << endl; return; } int mid = (l + r - 1) / 2; if (add) { prev += mid; } else { prev -= mid; } assert(vis.insert(prev).second); cout << "? " << prev << endl; int ans; cin >> ans; if (ans) { solve(l, mid, prev, !add); } else { solve(mid + 1, r, prev, !add); } } void solve() { cin >> n; int start = search(1, n, true); dbg(start); cout << "? " << start << endl; int _; cin >> _; solve(1, n, start, true); } int main() { ios_base::sync_with_stdio(false); cin.exceptions(ios::failbit); solve(); }
#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...