Submission #166551

#TimeUsernameProblemLanguageResultExecution timeMemory
166551NaimSSCarnival (CEOI14_carnival)C++14
20 / 100
121 ms376 KiB
#include <bits/stdc++.h> using namespace std; int pai[155]; int cor[155]; int find(int x){ return (x==pai[x] ? x : pai[x]= find(pai[x])); } void join(int a,int b){ a = find(a); b = find(b); pai[a] = b; } int main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n; cin>>n; cout<<n; for(int i=1;i<=n;i++)cout<<" "<<i; for(int i=1;i<=n;i++)pai[i] = i; cout<<endl; int C; cin>>C; int comp = n; for(int i=1;i<=n;i++)cor[i] = -1; int cur=1; for(int i=1;i<=n;i++){ if(cor[i]!=-1)continue; cor[i] = cur; for(int j=i+1;j<=n;j++){ if(comp==C)break; cout<<2<<" "<<i<<" "<<j<<endl; int s; cin>>s; if(s==1){ cor[j] = cur; join(i,j); comp--; } } cur++; } for(int i=1;i<=n;i++){ if(cor[i]==-1){ cor[i]=cur; cur++; } } cout<<0; for(int i=1;i<=n;i++)cout<<" "<<cor[i]; cout<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...