Submission #164473

# Submission time Handle Problem Language Result Execution time Memory
164473 2019-11-21T02:24:29 Z mhy908 Carnival (CEOI14_carnival) C++14
100 / 100
26 ms 380 KB
#include <bits/stdc++.h>
int query(int a, int b){
    printf("%d ", b-a+1);
    for(int i=a; i<=b; i++)printf("%d ", i);
    fflush(stdout);
    int ret;
    scanf("%d", &ret);
    return ret;
}
int n, col[160], r, sum[160];
int main()
{
    scanf("%d", &n);
    col[1]=sum[1]=++r;
    for(int i=2; i<=n; i++){
        sum[i]=query(1, i);
        if(sum[i-1]+1==sum[i]){
            col[i]=++r;
            continue;
        }
        else{
            int s=1, e=i-1;
            while(s<e){
                int mid=(s+e)/2+1;
                if(query(mid, i)==query(mid, i-1)+1)e=mid-1;
                else s=mid;
            }
            col[i]=col[s];
        }
    }
    for(int i=0; i<=n; i++)printf("%d ", col[i]);
}

Compilation message

carnival.cpp: In function 'int query(int, int)':
carnival.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &ret);
     ~~~~~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:13: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 Correct 24 ms 376 KB Output is correct
2 Correct 20 ms 248 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Correct 6 ms 248 KB Output is correct
5 Correct 21 ms 248 KB Output is correct
6 Correct 21 ms 376 KB Output is correct
7 Correct 26 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 296 KB Output is correct
2 Correct 21 ms 248 KB Output is correct
3 Correct 9 ms 248 KB Output is correct
4 Correct 5 ms 248 KB Output is correct
5 Correct 21 ms 248 KB Output is correct
6 Correct 21 ms 376 KB Output is correct
7 Correct 22 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 376 KB Output is correct
2 Correct 24 ms 296 KB Output is correct
3 Correct 17 ms 296 KB Output is correct
4 Correct 6 ms 248 KB Output is correct
5 Correct 22 ms 248 KB Output is correct
6 Correct 19 ms 380 KB Output is correct
7 Correct 21 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 248 KB Output is correct
2 Correct 24 ms 248 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 6 ms 248 KB Output is correct
5 Correct 19 ms 376 KB Output is correct
6 Correct 17 ms 248 KB Output is correct
7 Correct 20 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 376 KB Output is correct
2 Correct 23 ms 376 KB Output is correct
3 Correct 16 ms 376 KB Output is correct
4 Correct 13 ms 376 KB Output is correct
5 Correct 13 ms 248 KB Output is correct
6 Correct 9 ms 248 KB Output is correct
7 Correct 7 ms 248 KB Output is correct