Submission #1105467

# Submission time Handle Problem Language Result Execution time Memory
1105467 2024-10-26T13:13:19 Z lkateris Carnival (CEOI14_carnival) C++17
100 / 100
6 ms 512 KB
#include <iostream>
#include <vector>

using namespace std;

vector<int> L;

int printq(int a,int b,int n) {
    printf("%d",b-a+2);
    for(int i = a;i<=b;++i) {
        printf(" %d",L[i]);
    }
    printf(" %d\n",n);
    fflush(stdout);
    int res = 0;
    scanf("%d",&res);
    return res;
}

int main()
{
    
    int N;
    scanf("%d",&N);
    int cost[N+5];
    cost[1] = 1;
    int cnt = 1;
    L.push_back(1);
    for(int i=2;i<=N;++i) {
        int q = printq(0,cnt-1,i);
        if (q > cnt) {
            L.push_back(i);
            cnt++;
            cost[i] = cnt;
        }
        else {
            int l=0;
            int r=cnt-1;
            int m=(l+r)/2;
            while (l < r) {
                q = printq(l,m,i);
                if (q > m-l+1) l = m+1;
                else r = m;
                m=(l+r)/2; 
            }
            cost[i] = cost[L[r]];
        }
    }
    printf("0");
    for(int i=1;i<=N;++i) {
        printf(" %d",cost[i]);
    }
    printf("\n");
    fflush(stdout);
    return 0;
}

Compilation message

carnival.cpp: In function 'int printq(int, int, int)':
carnival.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d",&res);
      |     ~~~~~^~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 336 KB Output is correct
2 Correct 6 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 5 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 6 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 3 ms 336 KB Output is correct
5 Correct 5 ms 336 KB Output is correct
6 Correct 6 ms 336 KB Output is correct
7 Correct 5 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 4 ms 336 KB Output is correct
3 Correct 5 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 5 ms 336 KB Output is correct
6 Correct 5 ms 336 KB Output is correct
7 Correct 5 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 336 KB Output is correct
2 Correct 4 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 6 ms 336 KB Output is correct
6 Correct 5 ms 336 KB Output is correct
7 Correct 6 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 6 ms 336 KB Output is correct
3 Correct 5 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 5 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 3 ms 336 KB Output is correct