제출 #204381

#제출 시각아이디문제언어결과실행 시간메모리
204381ADJASplit the Attractions (IOI19_split)C++14
0 / 100
6 ms2808 KiB
#include "split.h" #include <iostream> #include <cstdio> #include <cstdlib> #include <vector> #include <set> #include <map> #include <algorithm> #include <bitset> #include <cmath> #include <queue> #include <stack> #include <string> #define sz(x) (int) x.size() #define all(x) x.begin(), x.end() using namespace std; const int MAXN = 105000; int n, a, b, c; vector<int> g[MAXN]; vector<int> res; int deg[MAXN]; bool used[MAXN]; void doPaint(int v, int num) { used[v] = true; if (num <= a) { res[v] = 1; } else if (num <= a + b) { res[v] = 2; } else { res[v] = 3; } for (int to : g[v]) { if (used[to]) { continue; } doPaint(to, num + 1); } } void solveOne() { int st = 0; for (int i = 0; i < n; i++) { if (deg[i] == 1) { st = i; } } doPaint(st, 1); } vector<int> find_split(int N, int A, int B, int C, vector<int> FROM, vector<int> TO) { n = N; a = A; b = B; c = C; res.assign(n, 0); for (int i = 0; i < sz(FROM); i++) { int from = FROM[i], to = TO[i]; deg[from]++; deg[to]++; } int mxDeg = deg[0]; for (int i = 0; i < n; i++) { mxDeg = max(mxDeg, deg[i]); } if (mxDeg <= 2) { solveOne(); return res; } 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...