# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25952 | kajebiii | Carnival (CEOI14_carnival) | C++14 | 16 ms | 2072 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;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;
const int MAX_N = 155;
const bool DEBUG = false;
int N, Nr[MAX_N], C, Ans[MAX_N];
int query(vector<int> &q) {
printf("%d ", SZ(q));
for(int x : q) printf("%d ", x); puts("");
fflush(stdout);
int res = 0;
if(DEBUG) {
set<int> S;
for(int x : q) S.insert(Nr[x]);
res = SZ(S);
} else {
scanf("%d", &res);
}
return res;
}
vector<int> List[MAX_N * 10]; pi It[MAX_N * 10];
vector<bool> chk;
vector<int> idx;
void findAns(int il, int ir) {
bool isOne = true;
vector<int> all;
chk = vector<bool>(N+1, false);
idx = vector<int>(N+1, -1);
for(int i=il; i<=ir; i++) {
if(SZ(List[i]) == 0) continue;
if(It[i].two != It[i].one) isOne = false;
vector<int> &nr = List[i];
// 1 to It[i].two - It[i].one + 1
int diff = (It[i].two - It[i].one + 2) / 2;
int ix = -1;
for(int l=0, r=SZ(nr)-1; l<=r; ) {
int m = (l+r) >> 1;
vector<int> q;
for(int k=0; k<=m; k++) q.push_back(nr[k]);
int c = query(q);
if(c == diff) {
ix = m;
break;
}else if(c < diff) l = m+1;
else r = m-1;
}
for(int k=0; k<=ix; k++) {
all.push_back(nr[k]);
List[i*2].push_back(nr[k]);
chk[nr[k]] = true;
}
for(int x : List[i]) idx[x] = i;
It[i*2] = pi(It[i].one, It[i].one + diff-1);
It[i*2+1] = pi(It[i].one + diff, It[i].two);
}
if(isOne) {
for(int i=il; i<=ir; i++) for(int x : List[i]) Ans[x] = It[i].one;
return;
}
int allC = query(all);
for(int i=1; i<=N; i++) if(chk[i] == false) {
all.push_back(i);
int nowC = query(all);
all.pop_back();
if(allC == nowC) List[idx[i] * 2].push_back(i);
else List[idx[i] * 2 + 1].push_back(i);
}
findAns(il*2, ir*2+1);
}
int main() {
scanf("%d", &N);
if(DEBUG) REPO(i, N) scanf("%d", &Nr[i]);
vector<int> all; REPO(i, N) all.push_back(i);
C = query(all);
List[1] = all;
It[1] = pi(1, C);
findAns(1, 1);
printf("0 ");
for(int i=1; i<=N; i++) printf("%d ", Ans[i]);
fflush(stdout);
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... |