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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
const int maxN=1e5+5;
vector<int> ans,g[maxN];
int used[maxN];
void dfs(int x, int &d, int c){
if(d<=0) return;
ans[x]=c;
used[x]=1;
for(auto it: g[x]){
if(used[it]) continue;
dfs(it,--d,c);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
int m=p.size();
ans.resize(n);
int A=a,B=b,C=c;
if(A>B) swap(A,B);
if(B>C) swap(B,C);
if(A>B) swap(A,B);
bool ok=1;
for(int i=0;i<m;i++){
g[p[i]].push_back(q[i]);
g[q[i]].push_back(p[i]);
}
for(int i=0;i<n;i++){
if(g[i].size()==1 && ok){
dfs(i,b,2);
ok=0;
}
else if(g[i].size()==1 && !ok){
dfs(i,a,1);
break;
}
}
if(ok){
dfs(0,b,2);
for(int i=0;i<n;i++){
if(!used[i]){
dfs(i,a,1);
break;
}
}
}
for(int i=0;i<n;i++){
if(!ans[i]) ans[i]=3;
}
return ans;
}
# | 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... |