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;
vector<int> n;
vector<int> v;
vector<vector<int> > l;
void dfs(int i, int count){
v[i]=count;
for (int j:l[i]){
if (v[j]<0){
dfs(j,count);
}
}
}
int main(){
int N;
cin >> N;
for (int i=1;i<=N;i++){
n.push_back(-1);
l.push_back(vector<int>());
v.push_back(-1);
}
for (int i=0;i<N;i++){
for (int j=i+1;j<N;j++){
cout << 2 << " "<< i+1 << " " << j+1 << endl;
int store;
cin >> store;
if (store==1) l[i].push_back(j);
}
}
int count = 1;
for (int i=0;i<N;i++){
if (v[i]<0){
dfs(i,count);
count++;
}
}
for (int i=0;i<N;i++){
cout << v[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... |