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>
using namespace std;
//#define int long long
map<pair<int,int>,int>mp;
map<pair<int,int>,int>vis;
int cnt=0;
int ask(int l,int r){
if(l==r){return 1;}
if(vis[{l,r}]){return mp[{l,r}];}
cnt++;
if(cnt==200001){
cout<<"! "<<7777777<<endl;
exit(0);
}
cout<<"? "<<l<<" "<<r<<endl;
int ret;
vis[{l,r}]=1;
cin>>ret;
mp[{l,r}]=ret;
return ret;
}
int n;
int rpl[300005];
int rask(int l,int r){
if(l==r){return 1;}
if(l%2==1){l++;}
if(r%2==1){r--;}
if(l==r){return 1;}
l=(l+1)/2;r=(r+1)/2;
return ask(l,r);
}
int par[300005];
//*#a#a#a#b#
signed main(){
cin>>n;
int l=1;int r=1;
int ans=1;
par[1]=1;
for(int i=2;i<=n+n+1-ans;i++){
int v=ans;
while( i-v>=1&&i+v<=n+n+1&&rask(i-v,i+v)){
v++;
}
ans=v;
}
cout<<"! "<<ans-1<<endl;
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:39:5: warning: unused variable 'l' [-Wunused-variable]
39 | int l=1;int r=1;
| ^
Main.cpp:39:13: warning: unused variable 'r' [-Wunused-variable]
39 | int l=1;int r=1;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |