Submission #239850

# Submission time Handle Problem Language Result Execution time Memory
239850 2020-06-17T12:00:57 Z brainwarego Carnival (CEOI14_carnival) C++14
0 / 100
4 ms 384 KB
#include <cstdio>

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

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

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

int main(){
    int N;
    scanf("%d", &N);
    for(int i=2;i<=N;++i){
        entry[en] = i;
        if(party(en+1, entry)==en+1){
            group[i] = ++en;
            continue;
        }
        int gnum = bsearch(0, en-1, i);
        group[i] = gnum;
    }
    printf("0 ");
    for(int i=1;i<=N;++i) printf("%d ", group[i]);
    puts("");
    return 0;
}

Compilation message

carnival.cpp: In function 'int party(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);
     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -