제출 #717914

#제출 시각아이디문제언어결과실행 시간메모리
717914bebraSplit the Attractions (IOI19_split)C++17
0 / 100
54 ms9176 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define dbg(x) cerr << #x << ": " << x << endl; const int MAX_N = 1e5 + 5; vector<int> g[MAX_N]; bool used[MAX_N]; int color[MAX_N]; int cnt; void dfs(int v) { --cnt; used[v] = true; color[v] = 2; if (cnt == 0) { return; } for (auto u : g[v]) { if (used[u]) continue; dfs(u); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { int m = p.size(); for (int i = 0; i < m; ++i) { int u = p[i]; int v = q[i]; g[u].push_back(v); g[v].push_back(u); } cnt = b; fill_n(color, n, 3); dfs(0); for (int v = 0; v < n; ++v) { if (color[v] == 3) { color[v] = 1; break; } } assert(b != 99998); vector<int> res(n); for (int i = 0; i < n; ++i) { res[i] = color[i]; } return res; } // int main() { // int n, m; // cin >> n >> m; // int a, b, c; // cin >> a >> b >> c; // vector<int> p(m), q(m); // for (int i = 0; i < m; ++i) { // cin >> p[i] >> q[i]; // } // for (auto x : find_split(n, a, b, c, p, q)) { // cout << x << ' '; // } // cout << '\n'; // }
#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...