Submission #748882

# Submission time Handle Problem Language Result Execution time Memory
748882 2023-05-27T06:21:15 Z 반딧불(#9966) Mađioničar (COI22_madionicar) C++17
63 / 100
1629 ms 1372 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(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]; i+l<=n+1 && i-l>=0; l++){
                    if(!query(i-l, i+l)) break;
                    arr[i] = l;
                }
            }
        }
        if(maxV < i+arr[i]) maxV = i+arr[i], maxMid = i;
    }

    for(int i=1; i<=n; i++){
        if(i%2) ans = max(ans, arr[i]);
        else    ans = max(ans, arr[i]);
    }

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

Compilation message

Main.cpp: In function 'bool query(int, int)':
Main.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d", &x);
      |     ~~~~~^~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 93 ms 440 KB Output is correct
2 Correct 158 ms 340 KB Output is correct
3 Correct 110 ms 308 KB Output is correct
4 Correct 110 ms 344 KB Output is correct
5 Correct 147 ms 328 KB Output is correct
6 Correct 111 ms 436 KB Output is correct
7 Correct 112 ms 436 KB Output is correct
8 Correct 143 ms 304 KB Output is correct
9 Correct 113 ms 456 KB Output is correct
10 Correct 109 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 93 ms 440 KB Output is correct
2 Correct 158 ms 340 KB Output is correct
3 Correct 110 ms 308 KB Output is correct
4 Correct 110 ms 344 KB Output is correct
5 Correct 147 ms 328 KB Output is correct
6 Correct 111 ms 436 KB Output is correct
7 Correct 112 ms 436 KB Output is correct
8 Correct 143 ms 304 KB Output is correct
9 Correct 113 ms 456 KB Output is correct
10 Correct 109 ms 588 KB Output is correct
11 Correct 706 ms 868 KB Output is correct
12 Correct 962 ms 968 KB Output is correct
13 Correct 1069 ms 940 KB Output is correct
14 Correct 840 ms 716 KB Output is correct
15 Correct 1099 ms 1164 KB Output is correct
16 Correct 815 ms 780 KB Output is correct
17 Correct 1037 ms 836 KB Output is correct
18 Correct 657 ms 932 KB Output is correct
19 Correct 1466 ms 804 KB Output is correct
20 Correct 1066 ms 880 KB Output is correct
21 Correct 622 ms 876 KB Output is correct
22 Correct 1148 ms 908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 796 ms 1296 KB Output is correct
2 Correct 908 ms 1092 KB Output is correct
3 Correct 963 ms 1108 KB Output is correct
4 Correct 1214 ms 1028 KB Output is correct
5 Correct 1522 ms 1116 KB Output is correct
6 Correct 807 ms 1012 KB Output is correct
7 Correct 1284 ms 1052 KB Output is correct
8 Correct 1234 ms 1140 KB Output is correct
9 Correct 1140 ms 1168 KB Output is correct
10 Correct 1222 ms 1232 KB Output is correct
11 Correct 1575 ms 984 KB Output is correct
12 Correct 1629 ms 1148 KB Output is correct
13 Correct 1349 ms 1372 KB Output is correct
14 Correct 1109 ms 1156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 93 ms 440 KB Output is correct
2 Correct 158 ms 340 KB Output is correct
3 Correct 110 ms 308 KB Output is correct
4 Correct 110 ms 344 KB Output is correct
5 Correct 147 ms 328 KB Output is correct
6 Correct 111 ms 436 KB Output is correct
7 Correct 112 ms 436 KB Output is correct
8 Correct 143 ms 304 KB Output is correct
9 Correct 113 ms 456 KB Output is correct
10 Correct 109 ms 588 KB Output is correct
11 Correct 706 ms 868 KB Output is correct
12 Correct 962 ms 968 KB Output is correct
13 Correct 1069 ms 940 KB Output is correct
14 Correct 840 ms 716 KB Output is correct
15 Correct 1099 ms 1164 KB Output is correct
16 Correct 815 ms 780 KB Output is correct
17 Correct 1037 ms 836 KB Output is correct
18 Correct 657 ms 932 KB Output is correct
19 Correct 1466 ms 804 KB Output is correct
20 Correct 1066 ms 880 KB Output is correct
21 Correct 622 ms 876 KB Output is correct
22 Correct 1148 ms 908 KB Output is correct
23 Correct 796 ms 1296 KB Output is correct
24 Correct 908 ms 1092 KB Output is correct
25 Correct 963 ms 1108 KB Output is correct
26 Correct 1214 ms 1028 KB Output is correct
27 Correct 1522 ms 1116 KB Output is correct
28 Correct 807 ms 1012 KB Output is correct
29 Correct 1284 ms 1052 KB Output is correct
30 Correct 1234 ms 1140 KB Output is correct
31 Correct 1140 ms 1168 KB Output is correct
32 Correct 1222 ms 1232 KB Output is correct
33 Correct 1575 ms 984 KB Output is correct
34 Correct 1629 ms 1148 KB Output is correct
35 Correct 1349 ms 1372 KB Output is correct
36 Correct 1109 ms 1156 KB Output is correct
37 Correct 1165 ms 1184 KB Output is correct
38 Runtime error 1517 ms 1060 KB Execution killed with signal 13
39 Halted 0 ms 0 KB -