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;
#define MAX_N (int) 1e5+5
vector<int> ad[MAX_N];
vector<int> res;
vector<bool> vis(MAX_N);
void dfs(int x,int a,int b,int c){
if(vis[x]) return;
vis[x] = 1;
if(a > 0){
res[x] = 1;
--a;
}else if(b > 0){
res[x] = 2;
--b;
}else{
res[x] = 3;
}
for(auto s: ad[x]){
dfs(s,a,b,c);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
for(int i = 0;i<(int)p.size();i++){
ad[p[i]].push_back(q[i]);
ad[q[i]].push_back(p[i]);
}
res.assign(n,0);
int start = 0;
for(int i = 0;i<n;i++){
if(ad[i].size() == 1){
start = i;
break;
}
}
dfs(start,a,b,c);
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... |