#include<bits/stdc++.h>
#define int long long
using namespace std;
int R[2][200000];
int32_t main()
{
//cin.tie(0);
//cout.tie(0);
//ios_base::sync_with_stdio(0);
int n;
cin>>n;
int maxx=0;
for(int j=0;j<=1;j++)
{
R[j][0]=0;
int rp=0;
int i=1;
while(i<=n)
{
while(i-rp-1>=1 && i+j+rp<=n)
{
cout<<"? "<<i-rp-1<<" "<<i+j+rp<<"\n";
int co;
cin>>co;
if(co==1)
rp++;
else break;
}
R[j][i]=rp;
int k=1;
while((R[j][i-k]!=rp-k)&&(k<rp))
{
R[j][i+k]=min(R[j][i-k],rp-k);
k++;
}
rp=max(rp-k,0LL);
i+=k;
}
}
for(int i=0;i<=1;i++)
for(int j=0;j<=n;j++)
maxx=max(maxx,R[i][j]*2+i);
cout<<"! "<<maxx;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
376 KB |
Output is correct |
2 |
Correct |
92 ms |
404 KB |
Output is correct |
3 |
Correct |
134 ms |
320 KB |
Output is correct |
4 |
Correct |
166 ms |
460 KB |
Output is correct |
5 |
Correct |
167 ms |
416 KB |
Output is correct |
6 |
Correct |
66 ms |
384 KB |
Output is correct |
7 |
Correct |
163 ms |
544 KB |
Output is correct |
8 |
Correct |
179 ms |
308 KB |
Output is correct |
9 |
Correct |
132 ms |
448 KB |
Output is correct |
10 |
Correct |
107 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
376 KB |
Output is correct |
2 |
Correct |
92 ms |
404 KB |
Output is correct |
3 |
Correct |
134 ms |
320 KB |
Output is correct |
4 |
Correct |
166 ms |
460 KB |
Output is correct |
5 |
Correct |
167 ms |
416 KB |
Output is correct |
6 |
Correct |
66 ms |
384 KB |
Output is correct |
7 |
Correct |
163 ms |
544 KB |
Output is correct |
8 |
Correct |
179 ms |
308 KB |
Output is correct |
9 |
Correct |
132 ms |
448 KB |
Output is correct |
10 |
Correct |
107 ms |
504 KB |
Output is correct |
11 |
Correct |
1211 ms |
1420 KB |
Output is correct |
12 |
Correct |
864 ms |
1400 KB |
Output is correct |
13 |
Correct |
939 ms |
1300 KB |
Output is correct |
14 |
Correct |
860 ms |
1228 KB |
Output is correct |
15 |
Correct |
796 ms |
1304 KB |
Output is correct |
16 |
Correct |
1354 ms |
1304 KB |
Output is correct |
17 |
Correct |
1247 ms |
1388 KB |
Output is correct |
18 |
Correct |
1117 ms |
1256 KB |
Output is correct |
19 |
Correct |
1164 ms |
1292 KB |
Output is correct |
20 |
Correct |
907 ms |
1440 KB |
Output is correct |
21 |
Correct |
1061 ms |
1384 KB |
Output is correct |
22 |
Correct |
878 ms |
1332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1344 ms |
1492 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
376 KB |
Output is correct |
2 |
Correct |
92 ms |
404 KB |
Output is correct |
3 |
Correct |
134 ms |
320 KB |
Output is correct |
4 |
Correct |
166 ms |
460 KB |
Output is correct |
5 |
Correct |
167 ms |
416 KB |
Output is correct |
6 |
Correct |
66 ms |
384 KB |
Output is correct |
7 |
Correct |
163 ms |
544 KB |
Output is correct |
8 |
Correct |
179 ms |
308 KB |
Output is correct |
9 |
Correct |
132 ms |
448 KB |
Output is correct |
10 |
Correct |
107 ms |
504 KB |
Output is correct |
11 |
Correct |
1211 ms |
1420 KB |
Output is correct |
12 |
Correct |
864 ms |
1400 KB |
Output is correct |
13 |
Correct |
939 ms |
1300 KB |
Output is correct |
14 |
Correct |
860 ms |
1228 KB |
Output is correct |
15 |
Correct |
796 ms |
1304 KB |
Output is correct |
16 |
Correct |
1354 ms |
1304 KB |
Output is correct |
17 |
Correct |
1247 ms |
1388 KB |
Output is correct |
18 |
Correct |
1117 ms |
1256 KB |
Output is correct |
19 |
Correct |
1164 ms |
1292 KB |
Output is correct |
20 |
Correct |
907 ms |
1440 KB |
Output is correct |
21 |
Correct |
1061 ms |
1384 KB |
Output is correct |
22 |
Correct |
878 ms |
1332 KB |
Output is correct |
23 |
Runtime error |
1344 ms |
1492 KB |
Execution killed with signal 13 |
24 |
Halted |
0 ms |
0 KB |
- |