Submission #575464

#TimeUsernameProblemLanguageResultExecution timeMemory
575464_karan_gandhiColors (BOI20_colors)C++17
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(v) v.begin(), v.end() #define endl '\n' #define pl(var) " [" << #var << ": " << (var) << "] " template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "[" << p.first << ", " << p.second << "]"; } template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { cout << "["; for(int i = 0; i < (int)v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";} ll int n;; bool query(ll int diff, ll int prev) { if (prev + diff > n) { cout << "? 1" << endl; cout.flush(); int s; cin >> s; prev = 1; } assert(prev + diff <= n); cout << "? " << prev + diff << endl; cout.flush(); int s; cin >> s; return (bool)s; } void solve() { cin >> n; int prev = 1; query(1, 0); ll int hi = n - 1; ll int lo = 1; ll int ans = n; while (hi >= lo) { int mid = (hi + lo) / 2; if (query(mid, prev)) { ans = mid; hi = mid - 1; } else { lo = mid + 1; } prev = mid; } cout << "= " << ans << endl; cout.flush(); } int main() { // ios::sync_with_stdio(false); // cin.tie(nullptr); int T = 1; // cin >> T; while (T--) solve(); 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...