#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
map<pii, int> mp;
int query(int l, int r) {
if(mp.count({ l, r })) return mp[{ l, r }];
cout << "? " << l << " " << r << endl;
int x;
cin >> x;
return mp[{ l, r }] = x;
}
int get1(int p, int d, int n) {
if(p - d < 1 || p + d > n) return 0;
return query(p - d, p + d);
}
int get2(int p, int d, int n) {
if(p - d + 1 < 1 || p + d > n) return 0;
return query(p - d + 1, p + d);
}
signed main() {
int n, ans1=0, ans2=0;
cin >> n;
for(int i=1; i<=n; i++)
while(get1(i, ans1+1, n)) ans1++;
for(int i=1; i+1<=n; i++)
while(get2(i, ans2+1, n)) ans2++;
cout << "! " << max(2 * ans1 + 1, 2 * ans2) << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
297 ms |
1352 KB |
Output is correct |
2 |
Correct |
275 ms |
1740 KB |
Output is correct |
3 |
Correct |
298 ms |
1588 KB |
Output is correct |
4 |
Correct |
299 ms |
2008 KB |
Output is correct |
5 |
Correct |
336 ms |
1640 KB |
Output is correct |
6 |
Correct |
293 ms |
1520 KB |
Output is correct |
7 |
Correct |
312 ms |
1688 KB |
Output is correct |
8 |
Correct |
288 ms |
1892 KB |
Output is correct |
9 |
Correct |
309 ms |
1844 KB |
Output is correct |
10 |
Correct |
294 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
297 ms |
1352 KB |
Output is correct |
2 |
Correct |
275 ms |
1740 KB |
Output is correct |
3 |
Correct |
298 ms |
1588 KB |
Output is correct |
4 |
Correct |
299 ms |
2008 KB |
Output is correct |
5 |
Correct |
336 ms |
1640 KB |
Output is correct |
6 |
Correct |
293 ms |
1520 KB |
Output is correct |
7 |
Correct |
312 ms |
1688 KB |
Output is correct |
8 |
Correct |
288 ms |
1892 KB |
Output is correct |
9 |
Correct |
309 ms |
1844 KB |
Output is correct |
10 |
Correct |
294 ms |
1740 KB |
Output is correct |
11 |
Correct |
2638 ms |
8992 KB |
Output is correct |
12 |
Correct |
2693 ms |
8880 KB |
Output is correct |
13 |
Correct |
2611 ms |
9288 KB |
Output is correct |
14 |
Correct |
2670 ms |
8676 KB |
Output is correct |
15 |
Correct |
2631 ms |
8908 KB |
Output is correct |
16 |
Correct |
2773 ms |
9416 KB |
Output is correct |
17 |
Correct |
2625 ms |
9156 KB |
Output is correct |
18 |
Correct |
2706 ms |
9132 KB |
Output is correct |
19 |
Correct |
2698 ms |
9336 KB |
Output is correct |
20 |
Correct |
2635 ms |
8436 KB |
Output is correct |
21 |
Correct |
2594 ms |
9004 KB |
Output is correct |
22 |
Correct |
2609 ms |
9232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4064 ms |
12940 KB |
Output is correct |
2 |
Correct |
3030 ms |
10356 KB |
Output is correct |
3 |
Correct |
4056 ms |
13344 KB |
Output is correct |
4 |
Correct |
4122 ms |
13324 KB |
Output is correct |
5 |
Correct |
4086 ms |
13368 KB |
Output is correct |
6 |
Correct |
4185 ms |
13108 KB |
Output is correct |
7 |
Correct |
4140 ms |
13408 KB |
Output is correct |
8 |
Correct |
4146 ms |
12920 KB |
Output is correct |
9 |
Correct |
4107 ms |
12856 KB |
Output is correct |
10 |
Correct |
4034 ms |
13612 KB |
Output is correct |
11 |
Correct |
4066 ms |
13380 KB |
Output is correct |
12 |
Correct |
4078 ms |
13812 KB |
Output is correct |
13 |
Correct |
4058 ms |
13288 KB |
Output is correct |
14 |
Correct |
4032 ms |
13144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
297 ms |
1352 KB |
Output is correct |
2 |
Correct |
275 ms |
1740 KB |
Output is correct |
3 |
Correct |
298 ms |
1588 KB |
Output is correct |
4 |
Correct |
299 ms |
2008 KB |
Output is correct |
5 |
Correct |
336 ms |
1640 KB |
Output is correct |
6 |
Correct |
293 ms |
1520 KB |
Output is correct |
7 |
Correct |
312 ms |
1688 KB |
Output is correct |
8 |
Correct |
288 ms |
1892 KB |
Output is correct |
9 |
Correct |
309 ms |
1844 KB |
Output is correct |
10 |
Correct |
294 ms |
1740 KB |
Output is correct |
11 |
Correct |
2638 ms |
8992 KB |
Output is correct |
12 |
Correct |
2693 ms |
8880 KB |
Output is correct |
13 |
Correct |
2611 ms |
9288 KB |
Output is correct |
14 |
Correct |
2670 ms |
8676 KB |
Output is correct |
15 |
Correct |
2631 ms |
8908 KB |
Output is correct |
16 |
Correct |
2773 ms |
9416 KB |
Output is correct |
17 |
Correct |
2625 ms |
9156 KB |
Output is correct |
18 |
Correct |
2706 ms |
9132 KB |
Output is correct |
19 |
Correct |
2698 ms |
9336 KB |
Output is correct |
20 |
Correct |
2635 ms |
8436 KB |
Output is correct |
21 |
Correct |
2594 ms |
9004 KB |
Output is correct |
22 |
Correct |
2609 ms |
9232 KB |
Output is correct |
23 |
Correct |
4064 ms |
12940 KB |
Output is correct |
24 |
Correct |
3030 ms |
10356 KB |
Output is correct |
25 |
Correct |
4056 ms |
13344 KB |
Output is correct |
26 |
Correct |
4122 ms |
13324 KB |
Output is correct |
27 |
Correct |
4086 ms |
13368 KB |
Output is correct |
28 |
Correct |
4185 ms |
13108 KB |
Output is correct |
29 |
Correct |
4140 ms |
13408 KB |
Output is correct |
30 |
Correct |
4146 ms |
12920 KB |
Output is correct |
31 |
Correct |
4107 ms |
12856 KB |
Output is correct |
32 |
Correct |
4034 ms |
13612 KB |
Output is correct |
33 |
Correct |
4066 ms |
13380 KB |
Output is correct |
34 |
Correct |
4078 ms |
13812 KB |
Output is correct |
35 |
Correct |
4058 ms |
13288 KB |
Output is correct |
36 |
Correct |
4032 ms |
13144 KB |
Output is correct |
37 |
Correct |
4003 ms |
13232 KB |
Output is correct |
38 |
Correct |
4054 ms |
13324 KB |
Output is correct |
39 |
Correct |
4048 ms |
13640 KB |
Output is correct |
40 |
Correct |
4011 ms |
13324 KB |
Output is correct |
41 |
Correct |
4166 ms |
13228 KB |
Output is correct |
42 |
Correct |
4177 ms |
13776 KB |
Output is correct |
43 |
Correct |
4085 ms |
13372 KB |
Output is correct |
44 |
Correct |
4042 ms |
13364 KB |
Output is correct |
45 |
Correct |
4098 ms |
13456 KB |
Output is correct |
46 |
Correct |
4111 ms |
13668 KB |
Output is correct |
47 |
Correct |
4046 ms |
13444 KB |
Output is correct |
48 |
Correct |
3997 ms |
13220 KB |
Output is correct |
49 |
Correct |
4168 ms |
13680 KB |
Output is correct |
50 |
Correct |
4029 ms |
13436 KB |
Output is correct |
51 |
Correct |
4017 ms |
13488 KB |
Output is correct |
52 |
Correct |
4150 ms |
13344 KB |
Output is correct |