# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
881430 | 12345678 | Carnival (CEOI14_carnival) | C++17 | 1 ms | 344 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;
const int nx=155;
int n, res, cnt, vs[nx], ans[nx];
vector<int> d[nx];
int query(vector<int> v)
{
printf("%d ", v.size());
for (auto x:v) printf("%d ", x);
printf("\n");
scanf("%d", &res);
return res;
}
void dfs(int u, int p)
{
vs[u]=1;
ans[u]=cnt;
for (auto v:d[u]) if (v!=p&&!vs[v]) dfs(v, u);
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++) for (int j=i+1; j<=n; j++) if (query(vector<int> {i, j})==2) d[i].push_back(j), d[j].push_back(i);
for (int i=1; i<=n; i++) if (!vs[i]) cnt++, dfs(i, i);
printf("0 ");
for (int i=1; i<=n; i++) printf("%d ", 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... |