This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
return 1;
int res;
cin >> res;
return res;
}
void sol(int N) {
vi col(N);
col[0] = 1;
vi distinct;
distinct.push_back(0);
rep(i,1,N) {
set<int> cand(all(distinct));
int bits = i ? (32 - __builtin_clz(i)) : 0;
rep(b,0,bits+1) {
vi q;
rep(j,0,i) {
if ((~j) & (1 << b)) q.push_back(j);
}
set<int> inq(all(q));
set<int> expected;
for (int w : q) expected.insert(col[w]);
q.push_back(i);
int res = query(q);
if (res > sz(expected)) {
rep(j,0,i) if (inq.count(j)) cand.erase(j);
} else {
rep(j,0,i) if (!inq.count(j)) cand.erase(j);
}
}
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;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int N;
cin >> N;
sol(N);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |