# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
770496 | Ahmed57 | Carnival (CEOI14_carnival) | C++17 | 0 ms | 208 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.
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
//DSU
int mn = 10001;
int pr[151];
int findleader(int x){
if(pr[x]==x){
return x;
}
return pr[x] = findleader(pr[x]);
}
bool samegroup(int x,int y){
int led1 = findleader(x);
int led2 = findleader(y);
return led1==led2;
}
void mergegroup(int x,int y){
int led1 = findleader(x);
int led2 = findleader(y);
if(led1==led2)return;
pr[led2] = led1;
}
int query(vector<int> x){
cout<<x.size()<<" ";
for(auto i:x){
cout<<i+1<<" ";
}
cout<<endl;
cout.flush();
int lol;cin>>lol;return lol;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n;
cin>>n;
for(int i = 0;i<n;i++)pr[i] = i;
int b = 13;
int vis[n] = {0};
for(int i = 0;i<n;i++){
if(vis[findleader(i)])continue;
for(int j = i-(i%b);j<n;j++){
if(j%b==0){
vector<int> lol = {i};
for(int e = j;e<min(n,j+b);e++){
if(e!=i){
lol.push_back(e);cout<<e<<endl;
}
}
if(query(lol)==lol.size())continue;
for(int e = j;e<min(n,j+b);e++){
if(e!=i){
if(query({i,e})==1){
mergegroup(i,e);
}
}
}
}
}
vis[i] = 1;
}
int vis2[n] = {0};
int z = 0;
cout<<"0 ";
for(int i = 0;i<n;i++){
if(!vis2[findleader(i)]){
vis2[findleader(i)] = ++z;
}
cout<<vis2[findleader(i)]<<" ";
}
cout<<endl;
cout.flush();
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... |