Submission #721422

# Submission time Handle Problem Language Result Execution time Memory
721422 2023-04-10T21:17:10 Z FatihSolak Carnival (CEOI14_carnival) C++17
100 / 100
10 ms 320 KB
#include <bits/stdc++.h>
#define N 200005
using namespace std;
int ans[N];
void solve(){
    int n;
    cin >> n;
    auto ask = [&](vector<int> v){
        cout << v.size() << ' ';
        for(auto u:v){
            cout << u << ' ';
        }
        cout << endl;
        int ret;
        cin >> ret;
        return ret;
    };
    auto print = [&](){
        cout << "0 ";
        for(int i = 1;i<=n;i++){
            cout << ans[i] << ' ';
        }
        cout << endl;
    };
    int cnt = 0;
    vector<int> v;
    for(int i = 1;i<=n;i++){
        v.push_back(i);
        if(ask(v) == v.size()){
            ans[i] = ++cnt;
            continue;
        }
        v.pop_back();
        auto tmp = v;
        while(tmp.size() > 1){
            vector<int> a;
            while(a.size() < tmp.size()){
                a.push_back(tmp.back());
                tmp.pop_back();
            }
            a.push_back(i);
            if(ask(a) != a.size()){
                a.pop_back();
                tmp = a;
            }
        }
        ans[i] = ans[tmp[0]];
    }
    print();
}

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    #ifdef Local
    cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Compilation message

carnival.cpp: In function 'void solve()':
carnival.cpp:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         if(ask(v) == v.size()){
      |            ~~~~~~~^~~~~~~~~~~
carnival.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             if(ask(a) != a.size()){
      |                ~~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 5 ms 320 KB Output is correct
4 Correct 3 ms 312 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 5 ms 316 KB Output is correct
4 Correct 3 ms 308 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 5 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 7 ms 312 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 7 ms 316 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 6 ms 308 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 6 ms 304 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 6 ms 312 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct