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 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 && ans==1) 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 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... |