Submission #575466

#TimeUsernameProblemLanguageResultExecution timeMemory
575466_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; void solve() { cin >> n; cout << "? 1" << endl; cout.flush(); int s; cin >> s; int hi = n, lo = 2; int prev = 1; for (int i = 0; i < n - 1; i++) { if (i % 2 == 0) { cout << "? " << hi-- << endl; cout.flush(); cin >> s; if (i == 0 && !s) { cout << "=" << n << endl; return; } if (!s) { cout << "= " << (abs(prev - (hi + 1))) << endl; return; } prev = hi + 1; } else { cout << "? " << lo++ << endl; cout.flush(); cin >> s; if (!s) { cout << "= " << (abs(prev - (lo - 1))) << endl; return; } prev = lo - 1; } } assert(0); } 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...