Submission #534632

#TimeUsernameProblemLanguageResultExecution timeMemory
534632katwamiawCarnival (CEOI14_carnival)C++14
20 / 100
106 ms576 KiB
#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)

carnival.cpp: In function 'int main()':
carnival.cpp:30:9: warning: unused variable 'r' [-Wunused-variable]
   30 |     int r=1 ;
      |         ^
#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...