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;
void get_order(int node,int par,vector<int> &order,vector<vector<int>> &gr){
order.push_back(node);
for(auto i:gr[node]){
if(i != par)get_order(i,node,order,gr);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<vector<int>> gr(n+1,vector<int>());
vector<int> order;
for(int i=0;i<(int)p.size();i++){
gr[p[i]].push_back(q[i]);
gr[q[i]].push_back(p[i]);
}
for(int i=0;i<n;i++){
if((int)gr[i].size() == 1){
get_order(i,-1,order,gr);
break;
}
}
vector<int> res(n,0);
int ind = 0;
while(a--){
res[order[ind++]] = 1;
}
while(b--){
res[order[ind++]] = 2;
}
while(ind < n){
res[order[ind++]] = 3;
}
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... |