#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define all(x) ((x).begin(),(x).end())
#define sz(x) ((int)(x).size())
bool ask(int l,int r){
cout << "? " << l << " " << r << endl;
bool ans; cin >> ans;
return ans;
}
void solve(){
int n;
cin >> n;
int ans=1,p=1;
int lp=0;
bool zipla=0;
for(int i=2;i<=n;i++){
if(p>1 && ask(p-1,i)){
p--;
lp=p;
zipla=0;
ans=max(ans,i-p+1);
continue;
}
while(p<i && !ask(p,i)){
p++;
if(zipla) {zipla=0;p=i;}
}
ans=max(ans,i-p+1);
if(lp-p<=1) zipla=1;
else zipla=0;
lp=p;
}
cout << "! " << ans << endl;
}
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
int t=1;//cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
344 KB |
Output is correct |
2 |
Correct |
70 ms |
344 KB |
Output is correct |
3 |
Correct |
49 ms |
344 KB |
Output is correct |
4 |
Correct |
110 ms |
344 KB |
Output is correct |
5 |
Correct |
68 ms |
344 KB |
Output is correct |
6 |
Correct |
81 ms |
344 KB |
Output is correct |
7 |
Correct |
60 ms |
344 KB |
Output is correct |
8 |
Correct |
86 ms |
344 KB |
Output is correct |
9 |
Correct |
65 ms |
340 KB |
Output is correct |
10 |
Correct |
67 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
344 KB |
Output is correct |
2 |
Correct |
70 ms |
344 KB |
Output is correct |
3 |
Correct |
49 ms |
344 KB |
Output is correct |
4 |
Correct |
110 ms |
344 KB |
Output is correct |
5 |
Correct |
68 ms |
344 KB |
Output is correct |
6 |
Correct |
81 ms |
344 KB |
Output is correct |
7 |
Correct |
60 ms |
344 KB |
Output is correct |
8 |
Correct |
86 ms |
344 KB |
Output is correct |
9 |
Correct |
65 ms |
340 KB |
Output is correct |
10 |
Correct |
67 ms |
344 KB |
Output is correct |
11 |
Correct |
846 ms |
340 KB |
Output is correct |
12 |
Correct |
629 ms |
344 KB |
Output is correct |
13 |
Correct |
618 ms |
344 KB |
Output is correct |
14 |
Correct |
927 ms |
344 KB |
Output is correct |
15 |
Correct |
622 ms |
596 KB |
Output is correct |
16 |
Correct |
913 ms |
344 KB |
Output is correct |
17 |
Correct |
564 ms |
344 KB |
Output is correct |
18 |
Correct |
790 ms |
344 KB |
Output is correct |
19 |
Correct |
621 ms |
344 KB |
Output is correct |
20 |
Correct |
700 ms |
344 KB |
Output is correct |
21 |
Correct |
710 ms |
344 KB |
Output is correct |
22 |
Correct |
603 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
952 ms |
432 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
344 KB |
Output is correct |
2 |
Correct |
70 ms |
344 KB |
Output is correct |
3 |
Correct |
49 ms |
344 KB |
Output is correct |
4 |
Correct |
110 ms |
344 KB |
Output is correct |
5 |
Correct |
68 ms |
344 KB |
Output is correct |
6 |
Correct |
81 ms |
344 KB |
Output is correct |
7 |
Correct |
60 ms |
344 KB |
Output is correct |
8 |
Correct |
86 ms |
344 KB |
Output is correct |
9 |
Correct |
65 ms |
340 KB |
Output is correct |
10 |
Correct |
67 ms |
344 KB |
Output is correct |
11 |
Correct |
846 ms |
340 KB |
Output is correct |
12 |
Correct |
629 ms |
344 KB |
Output is correct |
13 |
Correct |
618 ms |
344 KB |
Output is correct |
14 |
Correct |
927 ms |
344 KB |
Output is correct |
15 |
Correct |
622 ms |
596 KB |
Output is correct |
16 |
Correct |
913 ms |
344 KB |
Output is correct |
17 |
Correct |
564 ms |
344 KB |
Output is correct |
18 |
Correct |
790 ms |
344 KB |
Output is correct |
19 |
Correct |
621 ms |
344 KB |
Output is correct |
20 |
Correct |
700 ms |
344 KB |
Output is correct |
21 |
Correct |
710 ms |
344 KB |
Output is correct |
22 |
Correct |
603 ms |
344 KB |
Output is correct |
23 |
Runtime error |
952 ms |
432 KB |
Execution killed with signal 13 |
24 |
Halted |
0 ms |
0 KB |
- |