답안 #1036026

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036026 2024-07-27T02:22:31 Z sleepntsheep COVID tests (CEOI24_covid) C
10 / 100
10 ms 344 KB
#include <stdio.h>
#include <string.h>

int n, t;
double p;

char ask(char *q) {
    char result;
    printf("Q %s\n", q);
    fflush(stdout);
    scanf(" %c", &result);
    return result;
}

int main() {
    scanf("%d%lf%d", &n, &p, &t);

    if (t == 1) {
        char a[1001] = { 0 };
        for (int i = 0; i < n; ++i) {
            char q[1001] = { 0 };
            for (int j = 0; j < n; ++j)
                q[j] = '0' + (j == i);
            a[i] = (ask(q) == 'P') + '0';
        }
        printf("A %s\n", a);
        return 0;
    }

    int x = n / p;

    while (t--) {
        char a[1001] = { 0 };
        for (int i = 0; i < n; ++i)
            a[i] = '0';
        int at = 0;
        while (at < n) {
            char q[1001] = { 0 };
            for (int i = 0; i < n; ++i)
                q[i] = '0';
            for (int i = at; i < at + x && i < n; ++i)
                q[i] = '1';
            if (ask(q) == 'N') {
                at += x;
                continue;
            }

            int lb = at - 1, ub = n;
            while (ub - lb > 1) {
                int md = lb + (ub - lb) / 2;

                for (int i = 0; i < n; ++i)
                    q[i] = '0';
                for (int j = at; j <= md; ++j)
                    q[j] = '1';

                printf("Q %s\n", q);
                fflush(stdout);
                if (ask(q) == 'P') ub = md;
                else lb = md;
            }

            if (ub < n)
                a[ub] = '1';
            at = ub + 1;
        }

        printf("A %s\n", a);
        fflush(stdout);
        char verdict;
        scanf(" %c", &verdict);
        if ('W' == verdict)
            return 0;
    }
}

Compilation message

Main.c: In function 'ask':
Main.c:11:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf(" %c", &result);
      |     ^~~~~~~~~~~~~~~~~~~~~
Main.c: In function 'main':
Main.c:16:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d%lf%d", &n, &p, &t);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:71:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         scanf(" %c", &verdict);
      |         ^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB translate:wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Correct 7 ms 344 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 6 ms 344 KB Output is correct
8 Correct 6 ms 344 KB Output is correct
9 Correct 6 ms 344 KB Output is correct
10 Correct 6 ms 344 KB Output is correct
11 Correct 8 ms 344 KB Output is correct
12 Correct 10 ms 344 KB Output is correct
13 Correct 5 ms 344 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
17 Correct 7 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB translate:wrong
2 Halted 0 ms 0 KB -