Submission #533096

#TimeUsernameProblemLanguageResultExecution timeMemory
533096kabikaColors (BOI20_colors)C++17
0 / 100
1 ms200 KiB
#include <iostream> #include <vector> #include <algorithm> #include <math.h> using namespace std; typedef long long ll; constexpr ll INF = 1e18; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin >> n; vector<bool> vis(n + 1, 0); cout << "? 1\n"; vis[1] = 1; bool resp; cin >> resp; bool flag = 1; ll l = 1, u = n; ll diff = (l + u) / 2; ll qr = l + diff; while (l < u) { cout << "? " << qr << endl; vis[qr] = 1; cin >> resp; if (resp) { u = diff; } else { l = diff + 1; } diff = (l + u) / 2; if (qr - diff >= 1 && !vis[qr - diff]) { qr -= diff; continue; } if (qr + diff <= n && !vis[qr + diff]) { qr += diff; continue; } break; } cout << "= " << l << endl; return 0; }

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:21:7: warning: unused variable 'flag' [-Wunused-variable]
   21 |  bool flag = 1;
      |       ^~~~
#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...