제출 #385284

#제출 시각아이디문제언어결과실행 시간메모리
385284monus1042사육제 (CEOI14_carnival)C++17
0 / 100
93 ms512 KiB
#include <bits/stdc++.h> using namespace std; const int NAX = 200; int p[NAX]; int Find(int u){ if (p[u]==-1) return u; return p[u]=Find(p[u]); } int main(){ int n; cin>>n; memset(p, -1, sizeof p); for (int i=1; i<n; i++){ for (int j=i+1; j<=n; j++){ cout<<2<<' '<<i<<' '<<j<<endl; int ans; cin>>ans; int x=Find(i), y=Find(j); if (x!=y) p[i]=y; } } cout<<0<<' '; vector<int> color(NAX); int curr=0; for (int i=1; i<=n; i++){ if (p[i]==-1) color[i]=++curr; } for (int i=1; i<=n; i++){ int par=Find(i); color[i]=color[par]; } for (int i=1; i<=n; i++) cout<<color[i]<<' '; cout<<endl; 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...