답안 #938871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
938871 2024-03-05T17:38:04 Z sleepntsheep 사육제 (CEOI14_carnival) C
0 / 100
13 ms 344 KB
/*

   CARNIVAL -> https://www.youtube.com/watch?v=Fc7-Oe0tj5k
   CARNIVAL -> https://www.youtube.com/watch?v=Fc7-Oe0tj5k
   CARNIVAL -> https://www.youtube.com/watch?v=Fc7-Oe0tj5k
   CARNIVAL -> https://www.youtube.com/watch?v=Fc7-Oe0tj5k
   CARNIVAL -> https://www.youtube.com/watch?v=Fc7-Oe0tj5k
   CARNIVAL -> https://www.youtube.com/watch?v=Fc7-Oe0tj5k

   */


#include <stdio.h>
int n, a[150], m;
int ask(int l,int r,int i)
{
    printf("%d ",r-l+1+(!!~i));
    for (int i = l; i <= r; ++i) printf("%d ", i+1);
    if(~i) printf("%d", i+1);
    puts("");
    fflush(stdout);
    int x;
    scanf("%d", &x);
    return x;
}

int main()
{
    scanf("%d", &n);
    a[0] = ++m;
    for (int i = 1; i < n; ++i)
    {
        if (ask(0, i-1, -1) != ask(0, i-1, i))
        {
            a[i]=++m;
            continue;
        }
        int l = 0, r = i - 1;
        while (l < r)
        {
            int o = (l+r)/2;

            if (ask(l, o, -1) == ask(l, o, i))
            {
                r = o;
                continue;
            }
            else
            {
                l = o + 1;
            }
        }
        a[i] = a[l];
    }
    printf("0");
    for (int i = 0; i < n; ++i) printf(" %d", i);fflush(stdout);
}

Compilation message

carnival.c: In function 'main':
carnival.c:56:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   56 |     for (int i = 0; i < n; ++i) printf(" %d", i);fflush(stdout);
      |     ^~~
carnival.c:56:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   56 |     for (int i = 0; i < n; ++i) printf(" %d", i);fflush(stdout);
      |                                                  ^~~~~~
carnival.c: In function 'ask':
carnival.c:23:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d", &x);
      |     ^~~~~~~~~~~~~~~
carnival.c: In function 'main':
carnival.c:29:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%d", &n);
      |     ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 344 KB Integer 0 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 344 KB Integer 0 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 340 KB Integer 0 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 344 KB Integer 0 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 344 KB Integer 0 violates the range [1, 2]
2 Halted 0 ms 0 KB -