# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
585880 | stevancv | Carnival (CEOI14_carnival) | C++14 | 9 ms | 464 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 ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
int Ask(vector<int> a) {
int x = a.size();
cout << x << sp;
for (int u : a) cout << u + 1 << sp;
cout << en;
cout.flush();
cin >> x;
return x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n; cin >> n;
vector<int> p;
int pre = 0;
vector<int> tr;
vector<int> d(n, -1);
for (int i = 0; i < n; i++) {
tr.push_back(i);
int x = Ask(tr);
if (x != pre) {
d[i] = x - 1;
p.push_back(i);
}
pre = x;
}
int sz = p.size();
for (int i = 0; i < n; i++) {
if (d[i] != -1) continue;
int l = 0, r = sz - 1;
while (l < r) {
int mid = l + r >> 1;
tr.clear();
for (int j = l; j <= mid; j++) tr.push_back(p[j]);
tr.push_back(i);
int x = Ask(tr);
if (x == mid - l + 1) r = mid;
else l = mid + 1;
}
d[i] = l;
}
cout << "0 ";
for (int i = 0; i < n; i++) cout << d[i] + 1 << sp;
cout << en;
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... |