# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
749942 | vjudge1 | Carnival (CEOI14_carnival) | Java | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
////
using namespace std;
ll n, l, r;
ll ask(ll l, ll r)
{
cout << "? " << l << " " << r << '\n';
int res;
cin >> res;
return res;
}
int main()
{
cin >> n;
l = 1, r = n;
while(l < r)
{
ll ans1 = ask(l,r);
ll ans2 = ask(l+1,r);
ll ans3 = ask(l,r-1);
if(ans1 == ans2 and ans1 == ans3)
{
r--;
l++;
}
else if(ans1 != ans2)
{
cout << "! " << l;
return 0;
}
else if(ans1 != ans3)
{
cout <<"! "<< r;
return 0;
}
}
return 0;
}