# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
166671 | wilwxk | Carnival (CEOI14_carnival) | C++11 | 5 ms | 376 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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
const int MAXN=155;
int rep[MAXN], mp[MAXN];
vector<int> v;
int n, cnt;
void query(int cur, int ini, int fim) {
printf("query %d %d %d\n", cur, ini, fim);
if(fim<ini) return;
if(ini==fim) {
printf("2 %d %d\n", cur, v[ini]);
fflush(stdout);
int x; scanf("%d", &x);
if(x==1) rep[cur]=v[ini];
return;
}
int mid=(ini+fim)/2;
printf("%d %d ", mid-ini+2, cur);
for(int i=ini; i<=mid; i++) printf("%d ", v[i]);
printf("\n");
fflush(stdout);
int x; scanf("%d", &x);
if(x>mid-ini+1) ini=mid+1;
else fim=mid;
query(cur, ini, fim);
}
int main() {
scanf("%d", &n);
for(int i=1; i<=n; i++) rep[i]=i;
v.push_back(1);
for(int i=2; i<=n; i++) {
query(i, 0, v.size()-1);
if(rep[i]==i) v.push_back(i);
printf("%d >> %d\n", i, rep[i]);
}
printf("0 "); for(int i=1; i<=n; i++) {
if(!mp[rep[i]]) mp[rep[i]]=++cnt;
printf("%d ", mp[rep[i]]);
}
}
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... |