제출 #357702

#제출 시각아이디문제언어결과실행 시간메모리
357702mjhmjh1104Colors (BOI20_colors)C++14
22 / 100
5 ms256 KiB
#include <cstdio>

int n, t;

int main() {
    scanf("%d", &n);
    int curr = ((n + 1) / 2 - 1) / 2 * 2 + (n % 4 == 0) + 1;
    printf("? %d\n", curr);
    fflush(stdout);
    scanf("%*d");
    for (int i = 2; i < n; i += 2) {
        curr += (i % 4 ? 1 : -1) * i;
        printf("? %d\n", curr);
        fflush(stdout);
        scanf("%d", &t);
        if (t) {
            curr += (i % 4 ? -1 : 1) * (i - 1);
            printf("? %d\n", curr);
            fflush(stdout);
            scanf("%d", &t);
            if (t) printf("= %d\n", i - 1);
            else printf("= %d\n", i);
            fflush(stdout);
            return 0;
        }
    }
    if (n % 2) printf("= %d\n", n);
    else {
        if (curr == 1) curr += n - 1;
        else curr -= n - 1;
        printf("? %d\n", curr);
        fflush(stdout);
        scanf("%d", &t);
        if (t) printf("= %d\n", n - 1);
        else printf("= %d\n", n);
    }
    fflush(stdout);
}

컴파일 시 표준 에러 (stderr) 메시지

Colors.cpp: In function 'int main()':
Colors.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Colors.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     scanf("%*d");
      |     ~~~~~^~~~~~~
Colors.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |         scanf("%d", &t);
      |         ~~~~~^~~~~~~~~~
Colors.cpp:20:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |             scanf("%d", &t);
      |             ~~~~~^~~~~~~~~~
Colors.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |         scanf("%d", &t);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...