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 "split.h"
#include<bits/stdc++.h>
using namespace std;
vector< vector<int> > gr;
vector<int> val;
void go(int cur, int par, int ind, int n);
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
gr.resize(n + 5);
val.resize(n);
int m = p.size();
for (int i = 0; i < m; i++) {
int bg = p[i];
int en = q[i];
gr[en].push_back(bg);
gr[bg].push_back(en);
}
int uzuur = 0;
for (int i = 0; i < n; i++) {
if (gr[i].size() == 1) uzuur = i;
}
go (uzuur, -1, 1, n);
for (int i = 0; i < n; i++) {
if (val[i] <= a) {
val[i] = 1;
continue;
}
if (val[i] <= a + b) {
val[i] = 2;
continue;
}
val[i] = 3;
}
return val;
}
void go(int cur, int par, int ind, int n) {
val[cur] = ind;
if (ind == n) return;
for (int x : gr[cur]) {
if (x == par) continue;
go(x, cur, ind + 1, n);
}
}
# | 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... |