답안 #1027042

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027042 2024-07-18T19:15:16 Z VMaksimoski008 Mađioničar (COI22_madionicar) C++17
100 / 100
1370 ms 13880 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 1616 KB Output is correct
2 Correct 76 ms 1492 KB Output is correct
3 Correct 71 ms 1356 KB Output is correct
4 Correct 75 ms 1264 KB Output is correct
5 Correct 83 ms 1776 KB Output is correct
6 Correct 101 ms 1616 KB Output is correct
7 Correct 64 ms 1684 KB Output is correct
8 Correct 74 ms 1536 KB Output is correct
9 Correct 79 ms 1360 KB Output is correct
10 Correct 74 ms 1616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 1616 KB Output is correct
2 Correct 76 ms 1492 KB Output is correct
3 Correct 71 ms 1356 KB Output is correct
4 Correct 75 ms 1264 KB Output is correct
5 Correct 83 ms 1776 KB Output is correct
6 Correct 101 ms 1616 KB Output is correct
7 Correct 64 ms 1684 KB Output is correct
8 Correct 74 ms 1536 KB Output is correct
9 Correct 79 ms 1360 KB Output is correct
10 Correct 74 ms 1616 KB Output is correct
11 Correct 749 ms 9092 KB Output is correct
12 Correct 809 ms 9072 KB Output is correct
13 Correct 773 ms 8792 KB Output is correct
14 Correct 823 ms 8780 KB Output is correct
15 Correct 821 ms 8740 KB Output is correct
16 Correct 823 ms 8724 KB Output is correct
17 Correct 783 ms 8860 KB Output is correct
18 Correct 726 ms 8380 KB Output is correct
19 Correct 735 ms 8864 KB Output is correct
20 Correct 763 ms 8488 KB Output is correct
21 Correct 790 ms 8652 KB Output is correct
22 Correct 761 ms 8784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1276 ms 13080 KB Output is correct
2 Correct 951 ms 10356 KB Output is correct
3 Correct 1167 ms 13632 KB Output is correct
4 Correct 1150 ms 13864 KB Output is correct
5 Correct 1149 ms 13180 KB Output is correct
6 Correct 1154 ms 13880 KB Output is correct
7 Correct 1119 ms 13264 KB Output is correct
8 Correct 1142 ms 13192 KB Output is correct
9 Correct 1146 ms 13372 KB Output is correct
10 Correct 1190 ms 13128 KB Output is correct
11 Correct 1242 ms 13020 KB Output is correct
12 Correct 1251 ms 13600 KB Output is correct
13 Correct 1152 ms 12804 KB Output is correct
14 Correct 1191 ms 13188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 1616 KB Output is correct
2 Correct 76 ms 1492 KB Output is correct
3 Correct 71 ms 1356 KB Output is correct
4 Correct 75 ms 1264 KB Output is correct
5 Correct 83 ms 1776 KB Output is correct
6 Correct 101 ms 1616 KB Output is correct
7 Correct 64 ms 1684 KB Output is correct
8 Correct 74 ms 1536 KB Output is correct
9 Correct 79 ms 1360 KB Output is correct
10 Correct 74 ms 1616 KB Output is correct
11 Correct 749 ms 9092 KB Output is correct
12 Correct 809 ms 9072 KB Output is correct
13 Correct 773 ms 8792 KB Output is correct
14 Correct 823 ms 8780 KB Output is correct
15 Correct 821 ms 8740 KB Output is correct
16 Correct 823 ms 8724 KB Output is correct
17 Correct 783 ms 8860 KB Output is correct
18 Correct 726 ms 8380 KB Output is correct
19 Correct 735 ms 8864 KB Output is correct
20 Correct 763 ms 8488 KB Output is correct
21 Correct 790 ms 8652 KB Output is correct
22 Correct 761 ms 8784 KB Output is correct
23 Correct 1276 ms 13080 KB Output is correct
24 Correct 951 ms 10356 KB Output is correct
25 Correct 1167 ms 13632 KB Output is correct
26 Correct 1150 ms 13864 KB Output is correct
27 Correct 1149 ms 13180 KB Output is correct
28 Correct 1154 ms 13880 KB Output is correct
29 Correct 1119 ms 13264 KB Output is correct
30 Correct 1142 ms 13192 KB Output is correct
31 Correct 1146 ms 13372 KB Output is correct
32 Correct 1190 ms 13128 KB Output is correct
33 Correct 1242 ms 13020 KB Output is correct
34 Correct 1251 ms 13600 KB Output is correct
35 Correct 1152 ms 12804 KB Output is correct
36 Correct 1191 ms 13188 KB Output is correct
37 Correct 1140 ms 13240 KB Output is correct
38 Correct 1216 ms 13036 KB Output is correct
39 Correct 1244 ms 13064 KB Output is correct
40 Correct 1223 ms 12996 KB Output is correct
41 Correct 1293 ms 12848 KB Output is correct
42 Correct 1310 ms 13320 KB Output is correct
43 Correct 1370 ms 13216 KB Output is correct
44 Correct 1224 ms 12968 KB Output is correct
45 Correct 1300 ms 12928 KB Output is correct
46 Correct 1229 ms 13076 KB Output is correct
47 Correct 1154 ms 13044 KB Output is correct
48 Correct 1213 ms 13244 KB Output is correct
49 Correct 1167 ms 13024 KB Output is correct
50 Correct 1172 ms 12888 KB Output is correct
51 Correct 1140 ms 12720 KB Output is correct
52 Correct 1107 ms 12988 KB Output is correct