#include <bits/stdc++.h>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T >
using oset = tree < T, null_type, less < T > , rb_tree_tag, tree_order_statistics_node_update > ;
#define int long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
//#define endl '\n'
using ll = long long;
using ld = long double;
#define send ios::sync_with_stdio(false);
#define help cin.tie(0);
void solve(int T);
const int N = 1e5 + 10;
const int M = 405;
const int SQRT = sqrt(N);
const int LOG = 20;
const int INF = 1e18;
const int MOD = 45678;
const ld EPS = 1e-9;
int ans;
int n, m, q, l, r, x, y, mx, mn;
int32_t main(){
send help;
solve(1);
}
bool ask(int l,int r){
if(l < 0 || r >= n)return 0;
cout<<"? "<<l+1<<" "<<r+1<<endl;
bool a;
cin>>a;
return a;
}
void answer(int x){
cout<<"! "<<x<<endl;
exit(0);
}
void solve(int T){
cin>>n;
int o = 0;
int e = 0;
for(int i = 0;i<n;i++){
while(ask(i - o - 1, i + o + 1))o++;
while(ask(i - e, i + e + 1))e++;
}
answer(max(o * 2 + 1, 2 * e));
}
//Te molam da raboti !!
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
344 KB |
Output is correct |
2 |
Correct |
86 ms |
344 KB |
Output is correct |
3 |
Correct |
72 ms |
344 KB |
Output is correct |
4 |
Correct |
62 ms |
344 KB |
Output is correct |
5 |
Correct |
57 ms |
348 KB |
Output is correct |
6 |
Correct |
75 ms |
348 KB |
Output is correct |
7 |
Correct |
76 ms |
352 KB |
Output is correct |
8 |
Correct |
62 ms |
348 KB |
Output is correct |
9 |
Correct |
58 ms |
344 KB |
Output is correct |
10 |
Correct |
69 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
344 KB |
Output is correct |
2 |
Correct |
86 ms |
344 KB |
Output is correct |
3 |
Correct |
72 ms |
344 KB |
Output is correct |
4 |
Correct |
62 ms |
344 KB |
Output is correct |
5 |
Correct |
57 ms |
348 KB |
Output is correct |
6 |
Correct |
75 ms |
348 KB |
Output is correct |
7 |
Correct |
76 ms |
352 KB |
Output is correct |
8 |
Correct |
62 ms |
348 KB |
Output is correct |
9 |
Correct |
58 ms |
344 KB |
Output is correct |
10 |
Correct |
69 ms |
340 KB |
Output is correct |
11 |
Correct |
672 ms |
344 KB |
Output is correct |
12 |
Correct |
621 ms |
344 KB |
Output is correct |
13 |
Correct |
663 ms |
344 KB |
Output is correct |
14 |
Correct |
669 ms |
348 KB |
Output is correct |
15 |
Correct |
630 ms |
344 KB |
Output is correct |
16 |
Correct |
612 ms |
344 KB |
Output is correct |
17 |
Correct |
602 ms |
344 KB |
Output is correct |
18 |
Correct |
676 ms |
344 KB |
Output is correct |
19 |
Correct |
611 ms |
344 KB |
Output is correct |
20 |
Correct |
663 ms |
344 KB |
Output is correct |
21 |
Correct |
660 ms |
344 KB |
Output is correct |
22 |
Correct |
682 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
938 ms |
344 KB |
Output is correct |
2 |
Correct |
734 ms |
504 KB |
Output is correct |
3 |
Correct |
1022 ms |
344 KB |
Output is correct |
4 |
Correct |
997 ms |
344 KB |
Output is correct |
5 |
Correct |
992 ms |
344 KB |
Output is correct |
6 |
Correct |
1006 ms |
344 KB |
Output is correct |
7 |
Correct |
957 ms |
344 KB |
Output is correct |
8 |
Correct |
1091 ms |
344 KB |
Output is correct |
9 |
Correct |
977 ms |
344 KB |
Output is correct |
10 |
Correct |
1093 ms |
340 KB |
Output is correct |
11 |
Correct |
988 ms |
344 KB |
Output is correct |
12 |
Correct |
969 ms |
344 KB |
Output is correct |
13 |
Correct |
985 ms |
344 KB |
Output is correct |
14 |
Correct |
957 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
344 KB |
Output is correct |
2 |
Correct |
86 ms |
344 KB |
Output is correct |
3 |
Correct |
72 ms |
344 KB |
Output is correct |
4 |
Correct |
62 ms |
344 KB |
Output is correct |
5 |
Correct |
57 ms |
348 KB |
Output is correct |
6 |
Correct |
75 ms |
348 KB |
Output is correct |
7 |
Correct |
76 ms |
352 KB |
Output is correct |
8 |
Correct |
62 ms |
348 KB |
Output is correct |
9 |
Correct |
58 ms |
344 KB |
Output is correct |
10 |
Correct |
69 ms |
340 KB |
Output is correct |
11 |
Correct |
672 ms |
344 KB |
Output is correct |
12 |
Correct |
621 ms |
344 KB |
Output is correct |
13 |
Correct |
663 ms |
344 KB |
Output is correct |
14 |
Correct |
669 ms |
348 KB |
Output is correct |
15 |
Correct |
630 ms |
344 KB |
Output is correct |
16 |
Correct |
612 ms |
344 KB |
Output is correct |
17 |
Correct |
602 ms |
344 KB |
Output is correct |
18 |
Correct |
676 ms |
344 KB |
Output is correct |
19 |
Correct |
611 ms |
344 KB |
Output is correct |
20 |
Correct |
663 ms |
344 KB |
Output is correct |
21 |
Correct |
660 ms |
344 KB |
Output is correct |
22 |
Correct |
682 ms |
344 KB |
Output is correct |
23 |
Correct |
938 ms |
344 KB |
Output is correct |
24 |
Correct |
734 ms |
504 KB |
Output is correct |
25 |
Correct |
1022 ms |
344 KB |
Output is correct |
26 |
Correct |
997 ms |
344 KB |
Output is correct |
27 |
Correct |
992 ms |
344 KB |
Output is correct |
28 |
Correct |
1006 ms |
344 KB |
Output is correct |
29 |
Correct |
957 ms |
344 KB |
Output is correct |
30 |
Correct |
1091 ms |
344 KB |
Output is correct |
31 |
Correct |
977 ms |
344 KB |
Output is correct |
32 |
Correct |
1093 ms |
340 KB |
Output is correct |
33 |
Correct |
988 ms |
344 KB |
Output is correct |
34 |
Correct |
969 ms |
344 KB |
Output is correct |
35 |
Correct |
985 ms |
344 KB |
Output is correct |
36 |
Correct |
957 ms |
344 KB |
Output is correct |
37 |
Correct |
1075 ms |
344 KB |
Output is correct |
38 |
Correct |
1056 ms |
344 KB |
Output is correct |
39 |
Correct |
1002 ms |
344 KB |
Output is correct |
40 |
Correct |
1044 ms |
344 KB |
Output is correct |
41 |
Correct |
1039 ms |
344 KB |
Output is correct |
42 |
Correct |
1000 ms |
344 KB |
Output is correct |
43 |
Correct |
1022 ms |
344 KB |
Output is correct |
44 |
Correct |
1000 ms |
344 KB |
Output is correct |
45 |
Correct |
1070 ms |
344 KB |
Output is correct |
46 |
Correct |
1048 ms |
344 KB |
Output is correct |
47 |
Correct |
1037 ms |
344 KB |
Output is correct |
48 |
Correct |
962 ms |
344 KB |
Output is correct |
49 |
Correct |
972 ms |
344 KB |
Output is correct |
50 |
Correct |
1071 ms |
340 KB |
Output is correct |
51 |
Correct |
1051 ms |
344 KB |
Output is correct |
52 |
Correct |
974 ms |
344 KB |
Output is correct |