제출 #389718

#제출 시각아이디문제언어결과실행 시간메모리
389718SuhaibSawalha1Split the Attractions (IOI19_split)C++17
18 / 100
128 ms15020 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); vis.resize(n); for (int i = 0; i < m; ++i) { adj[p[i]].push_back(q[i]); adj[q[i]].push_back(p[i]); } array<int, 2> P[n]; for (int i = 0; i < n; ++i) { P[i] = {(int)adj[i].size(), i}; } sort(P, P + n); dfs(P[0][1]); 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...