Submission #601869

#TimeUsernameProblemLanguageResultExecution timeMemory
601869Minindu2006Split the Attractions (IOI19_split)C++14
0 / 100
453 ms1048576 KiB
#include "split.h" #include<bits/stdc++.h> using namespace std; int pathC = 0; vector<int> adj[100001], vis(100001, 0); void dfs(int i, vector<int> &res, int a, int b) { vis[i] = 1; if(pathC < a) res[i] = 1; else if(pathC < a + b) res[i] = 2; pathC++; for(auto a:adj[i]) { if(!vis[a]) dfs(i, res, a, b); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int> res(n, 3); int m = p.size(); for(int i=0;i<m;i++) { adj[p[i]].push_back(q[i]); adj[q[i]].push_back(p[i]); } int root = -1; for(int i=0;i<n;i++) if(adj[i].size() == 1) { root = i; break; } root = max(root, 0); dfs(root, res,a , b); return res; }
#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...