Submission #951348

#TimeUsernameProblemLanguageResultExecution timeMemory
951348temmieowoColors (BOI20_colors)C++14
9 / 100
1 ms596 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int MAX_N = 5e5+10; const int INF = 2e18; int cnt = 0; int n; set<int> ss; int ask(int p){ if (ss.find(p)!=ss.end()){ cerr << p << "被用過了\n"; assert(0); } ss.insert(p); if (cnt==64){ cout << "問太多次了\n"; assert(0); } cnt++; cout << "? " << p << endl; int res; cin >> res; return res; } void answer(int p){ cout << "= " << p << endl; exit(0); return; } void solve2(){ int ll = 1, rr = n; while (ll<=rr){ if (ask(ll)==0 && ll!=1){ answer(rr-ll+2); } ll++; if (!(ll<=rr)){ break; } if (ask(rr)==0){ answer(rr-ll+2); } rr--; } answer(1); return; } void solve1(){ // input cin >> n; // process if (n<=64){ solve2(); } int ll = 1, rr = n+1, ans = rr; int now = 1; while (ll<rr){ int mid = (ll+rr)/2; int xx = 1; int yy = 1; ask(xx); int res = ask(yy); if (res==1){ ans = mid; rr = mid; }else{ ll = mid+1; } now++; } answer(ans); return; } signed main(){ int t = 1; while (t--){ solve1(); } 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...