# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
534632 | katwamiaw | Carnival (CEOI14_carnival) | C++14 | 106 ms | 576 KiB |
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>
#define ll long long
using namespace std ;
//fflush(stdout) ;
const int max_n=159 ;
int c[max_n] ;
vector<int>v[max_n] ;
int r=1 ;
void dfs(int x , int par , int g){
if(c[x]!=200) return ;
c[x]=g ;
if(g==-1){
c[x]=r ;
r++ ;
}
for(int i:v[x]){
if(i!=par){
dfs(i,x,c[x]) ;
}
}
}
int main(){
int n ; cin >> n ;
for(int i=1 ; i<=n ; i++) c[i]=200 ;
int r=1 ;
for(int i=1 ; i<n ; i++){
for(int j=i+1 ; j<=n ; j++){
cout << "2 " << i << ' ' << j << '\n' ;
fflush(stdout) ;
int x ; cin >> x ;
if(x==1){
v[i].push_back(j) ;
v[j].push_back(i) ;
}
}
}
for(int i=1 ; i<=n ; i++) dfs(i,0,-1) ;
cout << 0 << ' ' ;
for(int i=1 ; i<=n ; i++) cout << c[i] << ' ' ;
}
Compilation message (stderr)
# | 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... |