답안 #25959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25959 2017-06-25T08:16:03 Z 시제연(#1089) 사육제 (CEOI14_carnival) C++
100 / 100
13 ms 2020 KB
#include <bits/stdc++.h>

using namespace std;

int n;

int color[160];
int rep[160];
int key = 0;

void bs(int idx) {
    int s = 1, e = key, i;
    while(s<e) {
        int m = (s+e)>>1;
        printf("%d ",m-s+2);
        for (i=s;i<=m;i++) printf("%d ",rep[i]);
        printf("%d\n",idx);
        fflush(stdout);
        int a;
        scanf("%d",&a);
        if (a==m-s+1) e = m;
        else s = m+1;
    }
    color[idx] = s;
}

int main() {
    int i, j;
    scanf("%d",&n);

    for (i=1;i<=n;i++) {
        printf("%d ",i);
        for (j=1;j<=i;j++) printf("%d ",j);
        printf("\n"); fflush(stdout);
        int val;
        scanf("%d",&val);
        if (key<val) {
            key=val;
            color[i] = key;
            rep[key] = i;
        }
    }
    for (i=1;i<=n;i++) {
        if (color[i]) continue;
        bs(i);
    }
    printf("0 ");
    for (i=1;i<=n;i++) printf("%d ",color[i]);
    printf("\n");

    return 0;
}

Compilation message

carnival.cpp: In function 'void bs(int)':
carnival.cpp:20:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a);
                       ^
carnival.cpp: In function 'int main()':
carnival.cpp:29:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
carnival.cpp:36:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&val);
                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2020 KB Output is correct
2 Correct 3 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 6 ms 2020 KB Output is correct
5 Correct 3 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 9 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 3 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 6 ms 2020 KB Output is correct
6 Correct 3 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2020 KB Output is correct
2 Correct 6 ms 2020 KB Output is correct
3 Correct 6 ms 2020 KB Output is correct
4 Correct 3 ms 2020 KB Output is correct
5 Correct 6 ms 2020 KB Output is correct
6 Correct 13 ms 2020 KB Output is correct
7 Correct 9 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 6 ms 2020 KB Output is correct
3 Correct 6 ms 2020 KB Output is correct
4 Correct 3 ms 2020 KB Output is correct
5 Correct 6 ms 2020 KB Output is correct
6 Correct 3 ms 2020 KB Output is correct
7 Correct 6 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 6 ms 2020 KB Output is correct
3 Correct 3 ms 2020 KB Output is correct
4 Correct 6 ms 2020 KB Output is correct
5 Correct 6 ms 2020 KB Output is correct
6 Correct 6 ms 2020 KB Output is correct
7 Correct 3 ms 2020 KB Output is correct