# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
369835 | 2021-02-22T15:12:24 Z | MilosMilutinovic | Split the Attractions (IOI19_split) | C++14 | 0 ms | 0 KB |
#include "split.h" #include <bits/stdc++.h> using namespace std; #define pb push_back const int mxN=1e5; vector<int> g[mxN], euler; bool was[mxN]; void dfs(int u) { assert(u>=0&&u<n); was[u]=true; euler.pb(u); for(int i:g[u]) if(!was[i]) dfs(i); } vector<int> find_split(int n, int a, int b, int c, vector<int> u, vector<int> v) { int m=(int)u.size(); for(int i=0; i<m; ++i) g[u[i]].pb(v[i]), g[v[i]].pb(u[i]); int root; for(int i=0; i<n; ++i) if((int)g[i].size()==1) root=i; dfs(root); vector<int> ans(n); for(int i:euler) { if(a>0) ans[i]=1, --a; else if(b>0) ans[i]=2, --b; else ans[i]=3; } return ans; } /*int main() { ios::sync_with_stdio(false); cin.tie(0); return 0; }*/