제출 #287484

#제출 시각아이디문제언어결과실행 시간메모리
287484Haunted_CppSplit the Attractions (IOI19_split)C++17
0 / 100
6 ms5248 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 5; vector<vector<int>> g(MAX_N); vector<int> euler; void dfs(int node, int p) { euler.emplace_back(node); for (auto to : g[node]) { if (to != p) { dfs(to, node); } } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int> in(n); const int m = p.size(); assert(m == n - 1); for (int i = 0; i < m; i++) { int st = p[i]; int et = q[i]; --st; --et; g[st].emplace_back(et); g[et].emplace_back(st); ++in[st]; ++in[et]; } for (int i = 0; i < n; i++) { if (in[i] == 1) { dfs(i, -1); break; } } vector<int> res(n); for (auto to : euler) { if (a) { res[to] = 1; --a; } else if (b) { res[to] = 2; --b; } else { res[to] = 3; } } 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...