제출 #1042178

#제출 시각아이디문제언어결과실행 시간메모리
1042178sleepntsheepCOVID tests (CEOI24_covid)C11
82.35 / 100
7047 ms348 KiB
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

int n, t;
double p;

char ask(char *q) {
    char result[2];
    printf("Q %s\n", q);
    fflush(stdout);
    scanf("%s", result);
    return result[0];
}

char a[1001] = { 0 }, q[1001] = { 0 };

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

    if (t == 1) {
        for (int i = 0; i < n; ++i) {
            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 = -1, y;

    double P_[] = { 0.001, 0.005256, 0.011546, 0.028545, 0.039856, 0.068648, 0.104571, 0.158765, 0.2 };
    int X_[] = { 505, 133, 70, 28, 16, 10, 8, 4, 4, };
    int Y_[] = { 722, 136, 74, 28, 16, 10, 8, 4, 4, };

    for (int i = 0; i < 9; ++i)
        if (P_[i] == p)
            x = X_[i], y = Y_[i];

    while (t--) {
        for (int i = 0; i < n; ++i)
            a[i] = '0';
        int at = 0;
        while (at < n) {
            char q[1001] = { 0 };

            if (y > 0) {
                int aa = n < at + y ? n : at + y;
                for (int i = 0; i < n; ++i) q[i] = '0';
                for (int i = at; i < aa; ++i) q[i] = '1';
                if (ask(q) == 'N') {
                    at = aa;
                    continue;
                }
            }

            int lb = at - 1, ub = at + x;

            if (ub > n)
                ub = n;
            int ub0 = ub;
            int nx = ub;


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

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

                if (ask(q) == 'P') ub = md, nx = md + 1;
                else lb = md;
            }

            if (ub < ub0)
                a[ub] = '1';
            at = nx;
        }

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

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

Main.c: In function 'ask':
Main.c:14:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%s", result);
      |     ^~~~~~~~~~~~~~~~~~~
Main.c: In function 'main':
Main.c:21:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d%lf%d", &n, &p, &t);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:86:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         scanf("%s", verdict);
      |         ^~~~~~~~~~~~~~~~~~~~
Main.c:51:33: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   51 |                 int aa = n < at + y ? n : at + y;
      |                              ~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...