Submission #745481

#TimeUsernameProblemLanguageResultExecution timeMemory
745481MohamedAliSaidaneSplit the Attractions (IOI19_split)C++14
0 / 100
71 ms10588 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 < m; i ++) { adj[P[i]].pb(Q[i]); adj[Q[i]].pb(P[i]); } int root; for(int i =0; i < n ;i ++) { if(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[i] = 3; else ans[i] = 2; } else ans[i] = 1; for(auto e: adj[root]) { if(e != prec) { root = e; break; } } prec = root; } 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...