#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;
for(int i=2;i<=n;i++){
if(ans>=2*n-i-p+1) break;
if(p>1 && ask(p-1,i)){
p--;
ans=max(ans,i-p+1);
continue;
}
while(p<i && !ask(p,i)) p++;
ans=max(ans,i-p+1);
}
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 |
102 ms |
344 KB |
Output is correct |
2 |
Correct |
70 ms |
344 KB |
Output is correct |
3 |
Correct |
62 ms |
344 KB |
Output is correct |
4 |
Correct |
107 ms |
344 KB |
Output is correct |
5 |
Correct |
89 ms |
344 KB |
Output is correct |
6 |
Correct |
96 ms |
344 KB |
Output is correct |
7 |
Correct |
58 ms |
344 KB |
Output is correct |
8 |
Correct |
133 ms |
344 KB |
Output is correct |
9 |
Correct |
91 ms |
344 KB |
Output is correct |
10 |
Correct |
73 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
102 ms |
344 KB |
Output is correct |
2 |
Correct |
70 ms |
344 KB |
Output is correct |
3 |
Correct |
62 ms |
344 KB |
Output is correct |
4 |
Correct |
107 ms |
344 KB |
Output is correct |
5 |
Correct |
89 ms |
344 KB |
Output is correct |
6 |
Correct |
96 ms |
344 KB |
Output is correct |
7 |
Correct |
58 ms |
344 KB |
Output is correct |
8 |
Correct |
133 ms |
344 KB |
Output is correct |
9 |
Correct |
91 ms |
344 KB |
Output is correct |
10 |
Correct |
73 ms |
344 KB |
Output is correct |
11 |
Correct |
969 ms |
344 KB |
Output is correct |
12 |
Correct |
751 ms |
344 KB |
Output is correct |
13 |
Correct |
676 ms |
344 KB |
Output is correct |
14 |
Correct |
1045 ms |
344 KB |
Output is correct |
15 |
Correct |
646 ms |
344 KB |
Output is correct |
16 |
Correct |
966 ms |
340 KB |
Output is correct |
17 |
Correct |
707 ms |
344 KB |
Output is correct |
18 |
Correct |
1006 ms |
344 KB |
Output is correct |
19 |
Correct |
950 ms |
344 KB |
Output is correct |
20 |
Correct |
853 ms |
344 KB |
Output is correct |
21 |
Correct |
781 ms |
344 KB |
Output is correct |
22 |
Correct |
761 ms |
356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
987 ms |
428 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
102 ms |
344 KB |
Output is correct |
2 |
Correct |
70 ms |
344 KB |
Output is correct |
3 |
Correct |
62 ms |
344 KB |
Output is correct |
4 |
Correct |
107 ms |
344 KB |
Output is correct |
5 |
Correct |
89 ms |
344 KB |
Output is correct |
6 |
Correct |
96 ms |
344 KB |
Output is correct |
7 |
Correct |
58 ms |
344 KB |
Output is correct |
8 |
Correct |
133 ms |
344 KB |
Output is correct |
9 |
Correct |
91 ms |
344 KB |
Output is correct |
10 |
Correct |
73 ms |
344 KB |
Output is correct |
11 |
Correct |
969 ms |
344 KB |
Output is correct |
12 |
Correct |
751 ms |
344 KB |
Output is correct |
13 |
Correct |
676 ms |
344 KB |
Output is correct |
14 |
Correct |
1045 ms |
344 KB |
Output is correct |
15 |
Correct |
646 ms |
344 KB |
Output is correct |
16 |
Correct |
966 ms |
340 KB |
Output is correct |
17 |
Correct |
707 ms |
344 KB |
Output is correct |
18 |
Correct |
1006 ms |
344 KB |
Output is correct |
19 |
Correct |
950 ms |
344 KB |
Output is correct |
20 |
Correct |
853 ms |
344 KB |
Output is correct |
21 |
Correct |
781 ms |
344 KB |
Output is correct |
22 |
Correct |
761 ms |
356 KB |
Output is correct |
23 |
Runtime error |
987 ms |
428 KB |
Execution killed with signal 13 |
24 |
Halted |
0 ms |
0 KB |
- |