This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "split.h"
using namespace std;
const int MAX_N = 1e5 + 5;
int N, M, A, B, C;
int sz[MAX_N];
vector <int> graph[MAX_N];
vector <int> res;
void dfs(int u, int p, int a) {
A--;
res[u] = a;
for(auto v : graph[u]) {
if(res[v] == p and A > 0) {
dfs(v, p, a);
}
}
}
vector <int> find_split(int n, int a, int b, int c, vector <int> p, vector <int> q) {
N = n, M = p.size(), A = a, B = b, C = c;
vector <int> tmp({A, B, C});
sort(tmp.begin(), tmp.end());
A = tmp[0], B = tmp[1], C = tmp[2];
for(int i = 0; i < M; i++) {
graph[p[i]].push_back(q[i]);
graph[q[i]].push_back(p[i]);
}
res.resize(N, 0);
dfs(0, 0, 1);
for(int i = 0; i < N; i++) {
if(res[i] == 0) {
A = B;
dfs(i, 0, 2);
if(A > 0) {
A = B;
dfs(i, 2, -1);
}
else {
break;
}
}
}
for(int i = 0; i < N; i++) {
if(res[i] != 1 and res[i] != 2) {
res[i] = 3;
}
}
if(A > 0) {
fill(res.begin(), res.end(), 0);
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |