Submission #667356

# Submission time Handle Problem Language Result Execution time Memory
667356 2022-12-01T07:37:45 Z RambaXGorilla Carnival (CEOI14_carnival) C++17
0 / 100
9 ms 208 KB
#include<cstdio>
using namespace std;
int N;
int costs[610];
int vis[155] = {};
int cnt = 1;
int party(int l, int r, int x = 0){
    printf("%d ",r - l + 1 + (bool) x);
    if(x) printf("%d ",x);
    for(int i = l;i < r + 1;i++){
        printf("%d ",i);
    }
    fflush(stdout);
    int y;
    scanf("%d",&y);
    return y;
}
void fillCosts(int v = 1, int tl = 1, int tr = N){
    if(tl == tr) return;
    costs[v] = party(tl, tr);
    int tm = (tl + tr) / 2;
    fillCosts(v * 2, tl, tm);
    fillCosts(v * 2 + 1, tm + 1, tr);
}
void travCosts(int x, int v = 1, int tl = 1, int tr = N){
    if(tr <= x){
        return;
    }
    if(tl == tr){
        if(party(tl, tl, x) == 1) vis[tl] = cnt;
        return;
    }
    if(tl > x && party(tl, tr, x) != costs[v]) return;
    int tm = (tl + tr) / 2;
    travCosts(x, v * 2, tl, tm);
    travCosts(x, v * 2 + 1, tm + 1, tr);
}
int main(){
    scanf("%d",&N);
    fillCosts();
    for(int i = 1;i < N + 1;i++){
        if(!vis[i]){
            travCosts(i);
            cnt++;
        }
    }
    printf("0 ");
    for(int i = 1;i < N + 1;i++){
        printf("%d ",vis[i]);
    }
}

Compilation message

carnival.cpp: In function 'int party(int, int, int)':
carnival.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d",&y);
      |     ~~~~~^~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 208 KB Integer 0 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 208 KB Integer 0 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 208 KB Integer 0 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 208 KB Integer 0 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 208 KB Integer 0 violates the range [1, 2]
2 Halted 0 ms 0 KB -