# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
364768 | ijxjdjd | Carnival (CEOI14_carnival) | C++14 | 7 ms | 364 KiB |
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>
#define FR(i, N) for (int i = 0; i < int(N); i++)
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
int query(vector<int> q) {
cout << q.size() << " ";
for (int a : q) {
cout << a << " ";
}
cout << endl;
int x;
cin >> x;
return x;
}
vector<int> merge(vector<vector<int>>& groups, int i) {
vector<int> res;
FR(j, i) {
res.insert(res.end(), all(groups[j]));
}
return res;
}
int main() {
cin.tie(0);
cin.sync_with_stdio(0);
int N;
cin >> N;
vector<vector<int>> groups;
groups.emplace_back();
groups[0].push_back(1);
vector<int> tot;
tot.push_back(1);
int ans[N];
ans[0] = 1;
for (int i = 2; i <= N; i++) {
tot.push_back(i);
if (query(tot) == groups.size() + 1) {
groups.emplace_back();
groups[groups.size()-1].push_back(i);
ans[i-1] = groups.size();
}
else {
int low = 0;
int high = groups.size()-1;
while (low < high) {
int mid = (low + high)/2;
if (query(merge(groups, mid+1)) == mid+1) {
high = mid;
}
else {
low = mid+1;
}
}
ans[i-1] = high+1;
groups[high].push_back(i);
}
}
cout << 0 << " ";
FR(i,N) {
cout << ans[i] << " ";
}
return 0;
}
Compilation message (stderr)
# | 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... |