Submission #389715

#TimeUsernameProblemLanguageResultExecution timeMemory
389715SuhaibSawalha1Split the Attractions (IOI19_split)C++17
0 / 100
75 ms8756 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; vector<bool> vis; int n, m; vector<int> ord, k, ans; void dfs (int u) { vis[u] = 1; for (int v : adj[u]) { if (!vis[v]) { dfs(v); } } ord.push_back(u); } void go (int i) { while (k[i]) { --k[i]; ans[ord.back()] = i + 1; ord.pop_back(); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { ::n = n; k = {a, b, c}; m = p.size(); adj.resize(n); ans.resize(n); for (int i = 0; i < m; ++i) { adj[p[i]].push_back(q[i]); adj[q[i]].push_back(p[i]); } vis.resize(n); for (int i = 0; i < n; ++i) { if (adj[i].size() == 1) { dfs(i); break; } } for (int i = 0; i < 3; ++i) { go(i); } return ans; }
#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...