Submission #748941

# Submission time Handle Problem Language Result Execution time Memory
748941 2023-05-27T07:37:39 Z 반딧불(#9966) Mađioničar (COI22_madionicar) C++17
63 / 100
1640 ms 1296 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
int arr[200002];
int ans;

bool query(int l, int r){
    assert(l%2 == r%2);
    if(l%2==0) return true;

    printf("? %d %d\n", (l+1)/2, (r+1)/2);
    fflush(stdout);
    int x;
    scanf("%d", &x);
    return x;
}

int main(){
    scanf("%d", &n);
    n = 2*n-1;
    int maxV = 0, maxMid = 0;
    for(int i=1; i<=n; i++){
        if((n-(i*2-n))/2+1 < ans) break;
        if(maxV < i){ /// �ٱ����̶� �� �� ���� ���
            for(int l=1; i+l<=n+1 && i-l>=0; l++){
                if(!query(i-l, i+l)) break;
                arr[i] = l;
            }
        }
        else{ /// ������ ���
            int m = maxMid, mlen = arr[m];
            int l = maxMid-mlen, r = maxMid+mlen;
            int q = i, p = m+m-q, plen = arr[p];
            if(p-plen > l) arr[q] = arr[p];
            else if(p-plen < l) arr[q] = r-q;
            else{
                arr[q] = p-l;
                for(int l=arr[q]+1; i+l<=n+1 && i-l>=0; l++){
                    if(!query(i-l, i+l)) break;
                    arr[q] = l;
                }
            }
        }
        if(maxV < i+arr[i]) maxV = i+arr[i], maxMid = i;
        ans = max(ans, arr[i]);
    }

    printf("! %d", ans);
}

Compilation message

Main.cpp: In function 'bool query(int, int)':
Main.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d", &x);
      |     ~~~~~^~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 93 ms 328 KB Output is correct
2 Correct 142 ms 344 KB Output is correct
3 Correct 134 ms 328 KB Output is correct
4 Correct 97 ms 432 KB Output is correct
5 Correct 155 ms 340 KB Output is correct
6 Correct 127 ms 420 KB Output is correct
7 Correct 79 ms 432 KB Output is correct
8 Correct 116 ms 316 KB Output is correct
9 Correct 177 ms 300 KB Output is correct
10 Correct 120 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 93 ms 328 KB Output is correct
2 Correct 142 ms 344 KB Output is correct
3 Correct 134 ms 328 KB Output is correct
4 Correct 97 ms 432 KB Output is correct
5 Correct 155 ms 340 KB Output is correct
6 Correct 127 ms 420 KB Output is correct
7 Correct 79 ms 432 KB Output is correct
8 Correct 116 ms 316 KB Output is correct
9 Correct 177 ms 300 KB Output is correct
10 Correct 120 ms 304 KB Output is correct
11 Correct 912 ms 956 KB Output is correct
12 Correct 985 ms 840 KB Output is correct
13 Correct 1078 ms 976 KB Output is correct
14 Correct 1000 ms 884 KB Output is correct
15 Correct 1111 ms 996 KB Output is correct
16 Correct 992 ms 688 KB Output is correct
17 Correct 1061 ms 716 KB Output is correct
18 Correct 953 ms 908 KB Output is correct
19 Correct 912 ms 948 KB Output is correct
20 Correct 1018 ms 880 KB Output is correct
21 Correct 664 ms 792 KB Output is correct
22 Correct 689 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 977 ms 1196 KB Output is correct
2 Correct 500 ms 572 KB Output is correct
3 Correct 813 ms 1152 KB Output is correct
4 Correct 1508 ms 1016 KB Output is correct
5 Correct 1640 ms 820 KB Output is correct
6 Correct 1101 ms 1088 KB Output is correct
7 Correct 1423 ms 796 KB Output is correct
8 Correct 1173 ms 1224 KB Output is correct
9 Correct 923 ms 1084 KB Output is correct
10 Correct 1182 ms 1216 KB Output is correct
11 Correct 1519 ms 692 KB Output is correct
12 Correct 1593 ms 752 KB Output is correct
13 Correct 1253 ms 1176 KB Output is correct
14 Correct 1276 ms 1188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 93 ms 328 KB Output is correct
2 Correct 142 ms 344 KB Output is correct
3 Correct 134 ms 328 KB Output is correct
4 Correct 97 ms 432 KB Output is correct
5 Correct 155 ms 340 KB Output is correct
6 Correct 127 ms 420 KB Output is correct
7 Correct 79 ms 432 KB Output is correct
8 Correct 116 ms 316 KB Output is correct
9 Correct 177 ms 300 KB Output is correct
10 Correct 120 ms 304 KB Output is correct
11 Correct 912 ms 956 KB Output is correct
12 Correct 985 ms 840 KB Output is correct
13 Correct 1078 ms 976 KB Output is correct
14 Correct 1000 ms 884 KB Output is correct
15 Correct 1111 ms 996 KB Output is correct
16 Correct 992 ms 688 KB Output is correct
17 Correct 1061 ms 716 KB Output is correct
18 Correct 953 ms 908 KB Output is correct
19 Correct 912 ms 948 KB Output is correct
20 Correct 1018 ms 880 KB Output is correct
21 Correct 664 ms 792 KB Output is correct
22 Correct 689 ms 852 KB Output is correct
23 Correct 977 ms 1196 KB Output is correct
24 Correct 500 ms 572 KB Output is correct
25 Correct 813 ms 1152 KB Output is correct
26 Correct 1508 ms 1016 KB Output is correct
27 Correct 1640 ms 820 KB Output is correct
28 Correct 1101 ms 1088 KB Output is correct
29 Correct 1423 ms 796 KB Output is correct
30 Correct 1173 ms 1224 KB Output is correct
31 Correct 923 ms 1084 KB Output is correct
32 Correct 1182 ms 1216 KB Output is correct
33 Correct 1519 ms 692 KB Output is correct
34 Correct 1593 ms 752 KB Output is correct
35 Correct 1253 ms 1176 KB Output is correct
36 Correct 1276 ms 1188 KB Output is correct
37 Correct 1131 ms 1172 KB Output is correct
38 Runtime error 1434 ms 1296 KB Execution killed with signal 13
39 Halted 0 ms 0 KB -