Submission #469110

#TimeUsernameProblemLanguageResultExecution timeMemory
469110Urvuk3Carnival (CEOI14_carnival)C++17
0 / 100
138 ms288 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int MAXN=155,MAXA=1e6+5,INF=1e9; const double EPS=1e-9; #define fi first #define se second #define pll pair<ll,ll> #define pii pair<int,int> #define mid (l+r)/2 #define sz(a) int((a).size()) #define all(a) a.begin(),a.end() #define mod 1000000007LL #define pb push_back #define PRINT(x) cerr<<#x<<'-'<<x<<endl<<flush; #define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());} #define pb push_back #define pf push_front #define ppf pop_front #define ppb pop_back #define PRINTvec(x) { cerr<<#x<<"-"; for(int i=0;i<sz(x);i++) cerr<<x[i]<<" "; cerr<<endl; } ll n,m,k,q,x,y,z,input; string s,t; ifstream in; vector<int> dsu; #ifdef ONLINE_JUDGE #define in cin #endif int root(int x){ while(x!=dsu[x]){ dsu[x]=dsu[dsu[x]]; x=dsu[x]; } return x; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; dsu.resize(n+1); iota(all(dsu),0); for(int i=1;i<=n;i++){ if(root(i)!=i) continue; //nije trenutni root set<int> roots; for(int j=1;j<=n;j++){ if(root(j)!=i) roots.insert(root(j)); } cout<<sz(roots)+1<<" "<<i<<" "; for(auto v:roots){ cout<<v<<" "; } cout<<endl; cin>>input; if(input==sz(roots)+1){ continue; } for(auto v:roots){ cout<<2<<" "<<i<<" "<<v<<endl; cin>>input; if(input==1){ dsu[i]=v; break; } } } vector<int> ret; map<int,int> mp; int tmp=0; for(int i=1;i<=n;i++){ ret.pb(root(i)); } for(int i=0;i<n;i++){ if(!mp[ret[i]]){ mp[ret[i]]=++tmp; } } for(int i=0;i<n;i++){ ret[i]=mp[ret[i]]; } cout<<0<<" "; for(auto v:ret){ cout<<v<<" "; } return 0; }
#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...