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<int> res;
vector<vector<int> > graph;
vector<bool> vis;
int aa, bb, cc;
void dfs(int pos){
// cout << pos << " " << a << " " << b << endl;
bool ae = true;
if (aa != 0) {
res[pos] = 1;
aa--;
}
else {
res[pos] = 2;
bb--;
}
vis[pos] = true;
for (int x : graph[pos]){
if(vis[x]) continue;
if (bb > 0) dfs(x);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
// cout << n << " " << a << " " << b << endl;
res.assign(n, 3);
int start = 0;
graph.assign(n, vector<int>(0));
vis.assign(n, false);
int m = p.size();
for (int i = 0; i < m; i++){
graph[p[i]].push_back(q[i]);
graph[q[i]].push_back(p[i]);
// cout << p[i] << " " << q[i] << endl;
}
for (int i = 0; i < n; i++){
if (graph[i].size() < 2) start = i;
}
aa = a, bb = b, cc = c;
dfs(start);
return res;
}
/*
6 5 2 2 2
0 1
1 2
2 3
3 4
4 5
*/
Compilation message (stderr)
split.cpp: In function 'void dfs(int)':
split.cpp:14:10: warning: unused variable 'ae' [-Wunused-variable]
14 | bool ae = true;
| ^~
# | 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... |