답안 #938873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
938873 2024-03-05T17:39:36 Z sleepntsheep 사육제 (CEOI14_carnival) C
100 / 100
16 ms 596 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", a[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", a[i]);fflush(stdout);
      |     ^~~
carnival.c:56:53: 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", a[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 Correct 9 ms 344 KB Output is correct
2 Correct 9 ms 596 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 11 ms 344 KB Output is correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 7 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 344 KB Output is correct
2 Correct 9 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 9 ms 596 KB Output is correct
6 Correct 11 ms 344 KB Output is correct
7 Correct 10 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 10 ms 344 KB Output is correct
3 Correct 9 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 10 ms 344 KB Output is correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 9 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 344 KB Output is correct
2 Correct 10 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 9 ms 344 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 9 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 344 KB Output is correct
2 Correct 13 ms 344 KB Output is correct
3 Correct 6 ms 344 KB Output is correct
4 Correct 6 ms 344 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct