답안 #239819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
239819 2020-06-17T10:45:11 Z brainwarego 사육제 (CEOI14_carnival) C++14
0 / 100
5 ms 384 KB
#include <cstdio>

int group[160] = {0, 1};
int entry[160] = {0, 1}, en = 1, arr[160];

int query(int len, int*ap){
    printf("%d ", len);
    for(int i=1;i<=len;++i) printf("%d ", ap[i]);
    puts("");
    int response;
    scanf("%d", &response);
    return response;
}

int bsearch(int s, int e, int tg){
    int m, ans = s;
    while(s <=  e){
        m = (s + e) / 2;
        for(int i=1;i<=m;++i) arr[i] = entry[i];
        arr[m+1] = tg;
        if(query(m+1, arr) < m+1){
            ans = m, e = m-1;
        }
        else s = m+1;
    }
    return entry[ans];
}

int main(){
    //freopen("input.txt", "r", stdin);
    int N;
    scanf("%d", &N);
    for(int i=2;i<=N;++i){
        entry[en + 1] = i;
        if(query(en+1, entry)==en+1){
            group[i] = i, ++en;
            continue;
        }
        int gnum = bsearch(1, en, i);
        group[i] = gnum;
    }
    printf("0 ");
    for(int i=1;i<=N;++i) printf("%d ", group[i]);

    return 0;
}

Compilation message

carnival.cpp: In function 'int query(int, int*)':
carnival.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &response);
     ~~~~~^~~~~~~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -