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 pb push_back
const int maxn = 1e5 + 5;
vector<int> graph[maxn];
int a, b, c;
//assume a is smallest
//assume b is second smallest
vector<int> ans;
int cnt = 0;
bool dfs(int n, int p){
cnt++;
ans[n] = 2;
if(cnt == b){
return true;
}
for(int adj : graph[n]){
if(adj == p) continue;
if(dfs(adj, n))
return true;
}
return cnt == b;
}
vector<int> find_split(int n, int a_, int b_, int c_, vector<int> p, vector<int> q) {
a = a_;
b = b_;
c = c_;
int m = p.size();
ans.assign(n, 0);
for(int i =0; i<m ;i++){
//cout << p[i] <<", "<<q[i]<<endl;
graph[p[i]].pb(q[i]);
graph[q[i]].pb(p[i]);
}
if(b)
dfs(0, -1);
int cntc = 0;
for(int i =0; i<n ;i++){
if(ans[i] == 0 and cntc < c){
cntc++;
ans[i] = 3;
}
else if (ans[i] == 0){
ans[i] = 1;
break;
}
}
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... |