#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ldb,ldb> pdd;
#define ff(i,a,b) for(int i = a; i <= b; i++)
#define fb(i,b,a) for(int i = b; i >= a; i--)
#define trav(a,x) for(auto& a : x)
#define sz(a) (int)(a).size()
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// os.order_of_key(k) the number of elements in the os less than k
// *os.find_by_order(k) print the k-th smallest number in os(0-based)
const int mod = 1000000007;
const int inf = 1e9 + 5;
const int mxN = 200005;
int n;
int ask(int l, int r){
cout << "? " << l << " " << r << endl;
int X;
cin >> X;
return X;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
int a = 1, b = 0;
ff(i,1,n){
while(i - a / 2 - 1 >= 1 && i + a / 2 + 1 <= n && ask(i - a / 2 - 1, i + a / 2 + 1) == 1){
a += 2;
}
while(i - b / 2 >= 1 && i + b / 2 + 1 <= n && ask(i - b / 2, i + b / 2 + 1) == 1){
b += 2;
}
}
cout << "! " << max(a, b) << endl;
return 0;
}
/*
// probati bojenje sahovski
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
94 ms |
208 KB |
Output is correct |
2 |
Correct |
95 ms |
208 KB |
Output is correct |
3 |
Correct |
126 ms |
208 KB |
Output is correct |
4 |
Correct |
121 ms |
208 KB |
Output is correct |
5 |
Correct |
93 ms |
208 KB |
Output is correct |
6 |
Correct |
44 ms |
208 KB |
Output is correct |
7 |
Correct |
74 ms |
208 KB |
Output is correct |
8 |
Correct |
91 ms |
208 KB |
Output is correct |
9 |
Correct |
106 ms |
208 KB |
Output is correct |
10 |
Correct |
115 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
94 ms |
208 KB |
Output is correct |
2 |
Correct |
95 ms |
208 KB |
Output is correct |
3 |
Correct |
126 ms |
208 KB |
Output is correct |
4 |
Correct |
121 ms |
208 KB |
Output is correct |
5 |
Correct |
93 ms |
208 KB |
Output is correct |
6 |
Correct |
44 ms |
208 KB |
Output is correct |
7 |
Correct |
74 ms |
208 KB |
Output is correct |
8 |
Correct |
91 ms |
208 KB |
Output is correct |
9 |
Correct |
106 ms |
208 KB |
Output is correct |
10 |
Correct |
115 ms |
208 KB |
Output is correct |
11 |
Correct |
642 ms |
208 KB |
Output is correct |
12 |
Correct |
931 ms |
208 KB |
Output is correct |
13 |
Correct |
712 ms |
208 KB |
Output is correct |
14 |
Correct |
715 ms |
208 KB |
Output is correct |
15 |
Correct |
618 ms |
208 KB |
Output is correct |
16 |
Correct |
886 ms |
208 KB |
Output is correct |
17 |
Correct |
805 ms |
208 KB |
Output is correct |
18 |
Correct |
989 ms |
312 KB |
Output is correct |
19 |
Correct |
991 ms |
208 KB |
Output is correct |
20 |
Correct |
813 ms |
208 KB |
Output is correct |
21 |
Correct |
925 ms |
208 KB |
Output is correct |
22 |
Correct |
804 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1100 ms |
208 KB |
Output is correct |
2 |
Correct |
993 ms |
208 KB |
Output is correct |
3 |
Correct |
1169 ms |
208 KB |
Output is correct |
4 |
Correct |
1262 ms |
208 KB |
Output is correct |
5 |
Correct |
983 ms |
208 KB |
Output is correct |
6 |
Correct |
1082 ms |
208 KB |
Output is correct |
7 |
Correct |
1138 ms |
208 KB |
Output is correct |
8 |
Correct |
1102 ms |
208 KB |
Output is correct |
9 |
Correct |
1150 ms |
316 KB |
Output is correct |
10 |
Correct |
1211 ms |
208 KB |
Output is correct |
11 |
Correct |
1168 ms |
208 KB |
Output is correct |
12 |
Correct |
1357 ms |
208 KB |
Output is correct |
13 |
Correct |
1509 ms |
320 KB |
Output is correct |
14 |
Correct |
1312 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
94 ms |
208 KB |
Output is correct |
2 |
Correct |
95 ms |
208 KB |
Output is correct |
3 |
Correct |
126 ms |
208 KB |
Output is correct |
4 |
Correct |
121 ms |
208 KB |
Output is correct |
5 |
Correct |
93 ms |
208 KB |
Output is correct |
6 |
Correct |
44 ms |
208 KB |
Output is correct |
7 |
Correct |
74 ms |
208 KB |
Output is correct |
8 |
Correct |
91 ms |
208 KB |
Output is correct |
9 |
Correct |
106 ms |
208 KB |
Output is correct |
10 |
Correct |
115 ms |
208 KB |
Output is correct |
11 |
Correct |
642 ms |
208 KB |
Output is correct |
12 |
Correct |
931 ms |
208 KB |
Output is correct |
13 |
Correct |
712 ms |
208 KB |
Output is correct |
14 |
Correct |
715 ms |
208 KB |
Output is correct |
15 |
Correct |
618 ms |
208 KB |
Output is correct |
16 |
Correct |
886 ms |
208 KB |
Output is correct |
17 |
Correct |
805 ms |
208 KB |
Output is correct |
18 |
Correct |
989 ms |
312 KB |
Output is correct |
19 |
Correct |
991 ms |
208 KB |
Output is correct |
20 |
Correct |
813 ms |
208 KB |
Output is correct |
21 |
Correct |
925 ms |
208 KB |
Output is correct |
22 |
Correct |
804 ms |
208 KB |
Output is correct |
23 |
Correct |
1100 ms |
208 KB |
Output is correct |
24 |
Correct |
993 ms |
208 KB |
Output is correct |
25 |
Correct |
1169 ms |
208 KB |
Output is correct |
26 |
Correct |
1262 ms |
208 KB |
Output is correct |
27 |
Correct |
983 ms |
208 KB |
Output is correct |
28 |
Correct |
1082 ms |
208 KB |
Output is correct |
29 |
Correct |
1138 ms |
208 KB |
Output is correct |
30 |
Correct |
1102 ms |
208 KB |
Output is correct |
31 |
Correct |
1150 ms |
316 KB |
Output is correct |
32 |
Correct |
1211 ms |
208 KB |
Output is correct |
33 |
Correct |
1168 ms |
208 KB |
Output is correct |
34 |
Correct |
1357 ms |
208 KB |
Output is correct |
35 |
Correct |
1509 ms |
320 KB |
Output is correct |
36 |
Correct |
1312 ms |
208 KB |
Output is correct |
37 |
Correct |
938 ms |
208 KB |
Output is correct |
38 |
Correct |
1006 ms |
208 KB |
Output is correct |
39 |
Correct |
1218 ms |
208 KB |
Output is correct |
40 |
Correct |
1364 ms |
208 KB |
Output is correct |
41 |
Correct |
1347 ms |
208 KB |
Output is correct |
42 |
Correct |
1102 ms |
208 KB |
Output is correct |
43 |
Correct |
1446 ms |
208 KB |
Output is correct |
44 |
Correct |
1334 ms |
208 KB |
Output is correct |
45 |
Correct |
1517 ms |
208 KB |
Output is correct |
46 |
Correct |
1275 ms |
208 KB |
Output is correct |
47 |
Correct |
1126 ms |
208 KB |
Output is correct |
48 |
Correct |
980 ms |
208 KB |
Output is correct |
49 |
Correct |
1368 ms |
208 KB |
Output is correct |
50 |
Correct |
1415 ms |
312 KB |
Output is correct |
51 |
Correct |
1113 ms |
208 KB |
Output is correct |
52 |
Correct |
1211 ms |
208 KB |
Output is correct |