#include "split.h"
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
const int mxn = 2e5 + 5;
vi adj[mxn]; vi ans; int cur = 0;
int a, b, c;
void dfs(int node, int prev, int i) {
ans[node] = i;
cur++;
//cout << node << " " << i << " " << cur << '\n';
if (i == 1) {if (cur == a) {i++; cur = 0;}}
else if (i == 2) {if (cur == b) {i++; cur = 0;}}
for (auto neighbour : adj[node]) {
if (neighbour == prev) continue;
dfs(neighbour, node, i);
}
}
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);
while (m--) {
int p, q;
cin >> p >> q;
adj[p].push_back(q); adj[q].push_back(p);
}
dfs(0, -1, 1);
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... |