#include<bits/stdc++.h>
using namespace std;
int n,cntq;
bool query(int le, int ri)
{
if(le<1 || ri>n || le>ri)
return 0;
if(le==ri)
return 1;
int aux;
cout<<"? "<<le<<" "<<ri<<endl;
cin>>aux;
return aux;
}
signed main()
{
cin>>n;
int mxm=1,p;
for(int i=1;i<n;i++)
{
p = mxm/2;
while(query(i-p,i+1+p))
p++;
mxm = max(mxm, 2*p);
}
for(int i=1;i<=n;i++)
{
p = (mxm+1)/2;
while(query(i-p,i+p))
p++;
mxm = max(mxm, 2*p-1);
}
cout<<"! "<<mxm<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
87 ms |
344 KB |
Output is correct |
2 |
Correct |
67 ms |
340 KB |
Output is correct |
3 |
Correct |
90 ms |
344 KB |
Output is correct |
4 |
Correct |
99 ms |
344 KB |
Output is correct |
5 |
Correct |
88 ms |
344 KB |
Output is correct |
6 |
Correct |
74 ms |
344 KB |
Output is correct |
7 |
Correct |
36 ms |
344 KB |
Output is correct |
8 |
Correct |
89 ms |
344 KB |
Output is correct |
9 |
Correct |
80 ms |
344 KB |
Output is correct |
10 |
Correct |
107 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
87 ms |
344 KB |
Output is correct |
2 |
Correct |
67 ms |
340 KB |
Output is correct |
3 |
Correct |
90 ms |
344 KB |
Output is correct |
4 |
Correct |
99 ms |
344 KB |
Output is correct |
5 |
Correct |
88 ms |
344 KB |
Output is correct |
6 |
Correct |
74 ms |
344 KB |
Output is correct |
7 |
Correct |
36 ms |
344 KB |
Output is correct |
8 |
Correct |
89 ms |
344 KB |
Output is correct |
9 |
Correct |
80 ms |
344 KB |
Output is correct |
10 |
Correct |
107 ms |
344 KB |
Output is correct |
11 |
Correct |
786 ms |
344 KB |
Output is correct |
12 |
Correct |
804 ms |
344 KB |
Output is correct |
13 |
Correct |
799 ms |
344 KB |
Output is correct |
14 |
Correct |
698 ms |
344 KB |
Output is correct |
15 |
Correct |
819 ms |
344 KB |
Output is correct |
16 |
Correct |
338 ms |
344 KB |
Output is correct |
17 |
Correct |
385 ms |
344 KB |
Output is correct |
18 |
Correct |
783 ms |
344 KB |
Output is correct |
19 |
Correct |
369 ms |
344 KB |
Output is correct |
20 |
Correct |
788 ms |
344 KB |
Output is correct |
21 |
Correct |
701 ms |
344 KB |
Output is correct |
22 |
Correct |
779 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1232 ms |
344 KB |
Output is correct |
2 |
Correct |
937 ms |
344 KB |
Output is correct |
3 |
Correct |
1121 ms |
344 KB |
Output is correct |
4 |
Correct |
694 ms |
344 KB |
Output is correct |
5 |
Correct |
551 ms |
344 KB |
Output is correct |
6 |
Correct |
1198 ms |
344 KB |
Output is correct |
7 |
Correct |
600 ms |
596 KB |
Output is correct |
8 |
Correct |
1115 ms |
344 KB |
Output is correct |
9 |
Correct |
1121 ms |
344 KB |
Output is correct |
10 |
Correct |
1142 ms |
344 KB |
Output is correct |
11 |
Correct |
569 ms |
344 KB |
Output is correct |
12 |
Correct |
567 ms |
344 KB |
Output is correct |
13 |
Correct |
1187 ms |
344 KB |
Output is correct |
14 |
Correct |
1191 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
87 ms |
344 KB |
Output is correct |
2 |
Correct |
67 ms |
340 KB |
Output is correct |
3 |
Correct |
90 ms |
344 KB |
Output is correct |
4 |
Correct |
99 ms |
344 KB |
Output is correct |
5 |
Correct |
88 ms |
344 KB |
Output is correct |
6 |
Correct |
74 ms |
344 KB |
Output is correct |
7 |
Correct |
36 ms |
344 KB |
Output is correct |
8 |
Correct |
89 ms |
344 KB |
Output is correct |
9 |
Correct |
80 ms |
344 KB |
Output is correct |
10 |
Correct |
107 ms |
344 KB |
Output is correct |
11 |
Correct |
786 ms |
344 KB |
Output is correct |
12 |
Correct |
804 ms |
344 KB |
Output is correct |
13 |
Correct |
799 ms |
344 KB |
Output is correct |
14 |
Correct |
698 ms |
344 KB |
Output is correct |
15 |
Correct |
819 ms |
344 KB |
Output is correct |
16 |
Correct |
338 ms |
344 KB |
Output is correct |
17 |
Correct |
385 ms |
344 KB |
Output is correct |
18 |
Correct |
783 ms |
344 KB |
Output is correct |
19 |
Correct |
369 ms |
344 KB |
Output is correct |
20 |
Correct |
788 ms |
344 KB |
Output is correct |
21 |
Correct |
701 ms |
344 KB |
Output is correct |
22 |
Correct |
779 ms |
344 KB |
Output is correct |
23 |
Correct |
1232 ms |
344 KB |
Output is correct |
24 |
Correct |
937 ms |
344 KB |
Output is correct |
25 |
Correct |
1121 ms |
344 KB |
Output is correct |
26 |
Correct |
694 ms |
344 KB |
Output is correct |
27 |
Correct |
551 ms |
344 KB |
Output is correct |
28 |
Correct |
1198 ms |
344 KB |
Output is correct |
29 |
Correct |
600 ms |
596 KB |
Output is correct |
30 |
Correct |
1115 ms |
344 KB |
Output is correct |
31 |
Correct |
1121 ms |
344 KB |
Output is correct |
32 |
Correct |
1142 ms |
344 KB |
Output is correct |
33 |
Correct |
569 ms |
344 KB |
Output is correct |
34 |
Correct |
567 ms |
344 KB |
Output is correct |
35 |
Correct |
1187 ms |
344 KB |
Output is correct |
36 |
Correct |
1191 ms |
344 KB |
Output is correct |
37 |
Correct |
1245 ms |
344 KB |
Output is correct |
38 |
Correct |
1168 ms |
344 KB |
Output is correct |
39 |
Correct |
1194 ms |
344 KB |
Output is correct |
40 |
Correct |
1127 ms |
340 KB |
Output is correct |
41 |
Correct |
1160 ms |
344 KB |
Output is correct |
42 |
Correct |
730 ms |
344 KB |
Output is correct |
43 |
Correct |
604 ms |
344 KB |
Output is correct |
44 |
Correct |
1173 ms |
344 KB |
Output is correct |
45 |
Correct |
616 ms |
344 KB |
Output is correct |
46 |
Correct |
1264 ms |
344 KB |
Output is correct |
47 |
Correct |
1162 ms |
344 KB |
Output is correct |
48 |
Correct |
1211 ms |
344 KB |
Output is correct |
49 |
Correct |
615 ms |
344 KB |
Output is correct |
50 |
Correct |
1157 ms |
344 KB |
Output is correct |
51 |
Correct |
1187 ms |
344 KB |
Output is correct |
52 |
Correct |
1166 ms |
344 KB |
Output is correct |