Submission #745485

#TimeUsernameProblemLanguageResultExecution timeMemory
745485MohamedAliSaidaneSplit the Attractions (IOI19_split)C++14
7 / 100
60 ms8820 KiB
#include <bits/stdc++.h> #include "split.h" using namespace std; typedef long long ll; typedef vector<int> vi; #define pb push_back #define ff first #define ss second const int nax = 1e5 + 4; int n, m, a, b, c; vi adj[nax]; vi find_split(int N, int A, int B, int C, vi P, vi Q) { n = N, a = A, b = B, c = C; m = P.size(); for(int i =0 ; i < n; i++) adj[i].clear(); for(int i = 0; i < m; i ++) { adj[P[i]].pb(Q[i]); adj[Q[i]].pb(P[i]); } int root = 0; for(int i =0; i < n ;i ++) { if((int)(adj[i].size()) == 1) root = i; } int prec = -1; vi ans(n); for(int i =0; i < n; i++) { if(i >= a) { if(i >= a + b) ans[root] = 3; else ans[root] = 2; } else ans[root] = 1; for(auto e: adj[root]) { if(e != prec) { prec = root; root = e; break; } } } return ans; } /* int32_t main() { int N, M, A, B, C; cin >> N >> M >> A >> B >> C; vi P(M), Q(M); for(int i = 0; i < M; i++) cin >> P[i] >> Q[i]; vi ANS = find_split(N, A, B, C, P, Q); for(auto e: ANS) cout << e << ' '; } */
#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...