Submission #601879

#TimeUsernameProblemLanguageResultExecution timeMemory
601879Minindu2006Split the Attractions (IOI19_split)C++14
18 / 100
81 ms18436 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; const int MX = 2e5 + 5; vector<int> adj[MX]; void dfs(int i, vector<int> &vis, vector<int> &path) { vis[i] = 1; path.push_back(i); for(int j:adj[i]) if(!vis[j]) dfs(j, vis, path); } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { 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); vector<int> vis(n, 0), path, res(n, 3); dfs(root, vis, path); for(int i=0;i<a;i++) res[path[i]] = 1; for(int i=a;i<a+b;i++) res[path[i]] = 2; 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...