Submission #750041

#TimeUsernameProblemLanguageResultExecution timeMemory
750041vjudge1Carnival (CEOI14_carnival)C++14
0 / 100
0 ms208 KiB
#include <bits/stdc++.h> #define ii pair<int,int> #define f first #define s second #define pb push_back #define int long long #define endl '\n' using namespace std; const int MAXN = 1e18; int mod = 1e9 + 7; struct data { int a,b,c; string s; }; int ask(int l,int r) { cout << "? " << l << " " << r << endl; int res; cin >> res; return res; } void AcSolution() { int n; cin >> n; int l = 1; int r = n; while(l < r) { if(r - l == 1) { int ans1 = ask(l,r); if(ans1 == r) { cout << "! " << l << endl; } else { cout << "! " << r << endl; } return; } int mid = (l + r) / 2; int ans1 = ask(l,r); if(ans1 < mid) { int ans2 = ask(l,mid); if(ans2 == ans1) { r = mid; } else { l = mid + 1; } } else { int ans2 = ask(mid,r); if(ans2 == ans1) { l = mid; } else { r = mid - 1; } } } cout << "! " << l << endl; } signed main() { int t = 1; // cin >> t; while(t--) { AcSolution(); } }
#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...