Submission #423962

#TimeUsernameProblemLanguageResultExecution timeMemory
423962schseSplit the Attractions (IOI19_split)C++17
0 / 100
1 ms332 KiB
#include "split.h" #include <bits/stdc++.h> #ifndef EVAL #include "grader.cpp" #endif using namespace std; struct node { vector<int> edges; bool been; }; vector<int> res; vector<int> order; vector<node> g; int A, B, C; void dfs(int n) { if (g[n].been) return; order.push_back(n); g[n].been = true; for (int i : g[n].edges) dfs(i); return; } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { A = a, B = b, C = c; g.resize(n); res.resize(n); for (int i = 0; i < n; i++) { g[p[i]].edges.push_back(q[i]); g[q[i]].edges.push_back(p[i]); } int stp = 0; for (stp = 0; stp < n; stp++) { if (g[stp].edges.size() == 1) { dfs(stp); break; } } if (stp == n) dfs(0); stp = 0; while (a--) { res[order[stp]] = 1; stp++; } while (b--) { res[order[stp]] = 2; stp++; } while (c--) { res[order[stp]] = 3; stp++; } 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...