Submission #1067518

# Submission time Handle Problem Language Result Execution time Memory
1067518 2024-08-20T19:16:11 Z jsannemo Carnival (CEOI14_carnival) C++14
0 / 100
6 ms 600 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int query(vi q) {
    if (sz(q) == 1) return 1;
    cout << q.size();
    for (int i : q) cout << " " << i + 1;
    cout << endl;
    int res;
    cin >> res;
    return res;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

    int N;
    cin >> N;

    vi col(N);
    col[0] = 1;
    vi distinct;
    distinct.push_back(0);

    rep(i,1,N) {
        set<int> cand(all(distinct));
        cerr << i << endl;

        int bits = i ? (32 - __builtin_clz(i)) : 0;
        rep(b,0,bits) {
            vi q;
            rep(j,0,i) {
                if (j & (1 << b)) q.push_back(j);
            }
            set<int> expected;
            for (int w : q) expected.insert(col[w]);

            q.push_back(i);
            int res = query(q);

            if (res > sz(expected)) {
                for (int w : q) {
                    if (cand.count(w)) {
                        cand.erase(w);
                    }
                }
            }
        }

        if (query({i, 0}) == 2) {
            if (cand.count(0)) cand.erase(0);
        }

        if (cand.empty()) {
            distinct.push_back(i);
            col[i] = sz(distinct);
        } else {
            assert(sz(cand) == 1);
            col[i] = col[*cand.begin()];
        }
    }

    cout << 0;
    rep(i,0,N) cout << " " << col[i];
    cout << endl;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -