Submission #1038203

#TimeUsernameProblemLanguageResultExecution timeMemory
1038203sleepntsheepCOVID tests (CEOI24_covid)C11
10 / 100
7 ms344 KiB
#include <stdio.h>
#include <math.h>
#include <stdlib.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;
}

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;

    double P_[] = { 0.001, 0.005256, 0.011546, 0.028545, 0.039856, 0.068648, 0.104571, 0.158765, 0.2 };
    int X_[] = { 1000, 999, 999, 254, 246, 126, 62, 31, 30 };
    for (int i = 0; i < 9; ++i) {
        if (fabs(P_[i] - p) < 0.001)
            x = X_[i];
    }

    if (x == -1)
        x = 999;
    x = 1000;

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

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

            if (ub > n)
                ub = n;
            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 < at + x)
                a[ub] = '1';
            at = nx;
        }

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

Compilation message (stderr)

Main.c: In function 'ask':
Main.c:13:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf(" %c", &result);
      |     ^~~~~~~~~~~~~~~~~~~~~
Main.c: In function 'main':
Main.c:20:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d%lf%d", &n, &p, &t);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:78:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         scanf(" %c", &verdict);
      |         ^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...