# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26171 | ruhanhabib39 | Carnival (CEOI14_carnival) | C++14 | 16 ms | 2020 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>
using namespace std;
int N;
vector<int> gp;
int res[150 + 10];
int query(vector<int> v) {
printf("%d", (int)v.size());
for(int i : v) {
printf(" %d", i);
}
printf("\n"); fflush(stdout);
int k; scanf("%d", &k);
return k;
}
int main() {
scanf("%d", &N);
gp.push_back(1);
for(int i = 2; i <= N; i++) {
gp.push_back(i);
if(query(gp) != gp.size()) {
gp.pop_back();
}
}
for(int i = 0; i < (int)gp.size(); i++) {
res[gp[i]] = i+1;
}
for(int i = 1; i <= N; i++) {
if(res[i]) continue;
int lo = 1, hi = gp.size();
while(lo < hi) {
int m = (lo + hi) / 2;
auto q = vector<int>(gp.begin(), gp.begin() + m);
q.push_back(i);
if(query(q) < q.size()) hi = m;
else lo = m+1;
}
res[i] = lo;
}
printf("0");
for(int i = 1; i <= N; i++) {
printf(" %d", res[i]);
}
printf("\n"); fflush(stdout);
}
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... |