Submission #544189

# Submission time Handle Problem Language Result Execution time Memory
544189 2022-04-01T09:49:47 Z krit3379 Carnival (CEOI14_carnival) C++14
100 / 100
9 ms 208 KB
#include<bits/stdc++.h>
using namespace std;
#define N 155

int type[N],head[N],ans[N];

int main(){
    int n,i,j,l,r,mid,x;
    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);
        scanf("%d",&type[i]);
        if(type[i]!=type[i-1])head[type[i]]=i;
    }
    for(i=1;i<=n;i++){
        if(head[type[i]]==i){
            ans[i]=type[i];
            continue;
        }
        l=1,r=type[i];
        while(l<r){
            mid=(l+r)/2;
            printf("%d ",mid-l+2);
            for(j=l;j<=mid;j++)printf("%d ",head[j]);
            printf("%d \n",i);
            fflush(stdout);
            scanf("%d",&x);
            if(x!=mid-l+1)l=mid+1;
            else r=mid;
        }
        ans[i]=l;
    }
    printf("0 ");
    for(i=1;i<=n;i++)printf("%d ",ans[i]);
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
carnival.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d",&type[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
carnival.cpp:30:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |             scanf("%d",&x);
      |             ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct