제출 #420544

#제출 시각아이디문제언어결과실행 시간메모리
420544SSRSSplit the Attractions (IOI19_split)C++14
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; void dfs(vector<vector<int>> &E, vector<bool> &used, vector<int> &d, int v){ d.push_back(v); for (int w : E[v]){ if (!used[w]){ used[w] = true; dfs(E, used, d, w); } } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q){ int m = p.size(); vector<vector<int>> E(n); for (int i = 0; i < m; i++){ E[p[i]].push_back(q[i]); E[q[i]].push_back(p[i]); } for (int i = 0; i < n; i++){ assert(E[i].size() <= 2); } int s = 0; for (int i = 0; i < n; i++){ if (E[i].size() == 1){ s = i; } } vector<bool> used(n, false); vector<int> d; dfs(E, used, d, s); vector<int> ans(n); for (int i = 0; i < a; i++){ ans[d[i]] = 1; } for (int i = a; i < a + b; i++){ ans[d[i]] = 2; } for (int i = a + b; i < a + b + c; i++){ ans[d[i]] = 3; } 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...