답안 #748872

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
748872 2023-05-27T05:58:08 Z 반딧불(#9966) Mađioničar (COI22_madionicar) C++17
13 / 100
1424 ms 288 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
int ans;

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        int L = 1, R = min(i-1, n-i), A = 0;
        while(L<=R){
            int M = (L+R)/2;
            printf("? %d %d\n", i-M, i+M);
            fflush(stdout);
            int x;
            scanf("%d", &x);
            if(x) A = M, L = M+1;
            else R = M-1;
        }
        ans = max(ans, A*2+1);
    }
    for(int i=1; i<n; i++){
        int L = 0, R = min(i-1, n-i-1), A = -1;
        while(L<=R){
            int M = (L+R)/2;
            printf("? %d %d\n", i-M, i+1+M);
            fflush(stdout);
            int x;
            scanf("%d", &x);
            if(x) A = M, L = M+1;
            else R = M-1;
        }
        ans = max(ans, A*2+2);
    }
    printf("! %d", ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |             scanf("%d", &x);
      |             ~~~~~^~~~~~~~~~
Main.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |             scanf("%d", &x);
      |             ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1228 ms 208 KB Output is correct
2 Correct 1088 ms 208 KB Output is correct
3 Correct 1135 ms 208 KB Output is correct
4 Correct 1303 ms 208 KB Output is correct
5 Correct 1305 ms 208 KB Output is correct
6 Correct 1332 ms 208 KB Output is correct
7 Correct 1328 ms 208 KB Output is correct
8 Correct 1424 ms 208 KB Output is correct
9 Correct 1086 ms 208 KB Output is correct
10 Correct 1049 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1228 ms 208 KB Output is correct
2 Correct 1088 ms 208 KB Output is correct
3 Correct 1135 ms 208 KB Output is correct
4 Correct 1303 ms 208 KB Output is correct
5 Correct 1305 ms 208 KB Output is correct
6 Correct 1332 ms 208 KB Output is correct
7 Correct 1328 ms 208 KB Output is correct
8 Correct 1424 ms 208 KB Output is correct
9 Correct 1086 ms 208 KB Output is correct
10 Correct 1049 ms 208 KB Output is correct
11 Runtime error 1213 ms 280 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1279 ms 288 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1228 ms 208 KB Output is correct
2 Correct 1088 ms 208 KB Output is correct
3 Correct 1135 ms 208 KB Output is correct
4 Correct 1303 ms 208 KB Output is correct
5 Correct 1305 ms 208 KB Output is correct
6 Correct 1332 ms 208 KB Output is correct
7 Correct 1328 ms 208 KB Output is correct
8 Correct 1424 ms 208 KB Output is correct
9 Correct 1086 ms 208 KB Output is correct
10 Correct 1049 ms 208 KB Output is correct
11 Runtime error 1213 ms 280 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -