# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
419061 | EncryptingWolf | Split the Attractions (IOI19_split) | C++14 | 0 ms | 0 KiB |
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 <vector>
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define FOR(i,x,y) for (ll i = x; i <y; i++)
vector<vector<int>> adj;
vector<int> ret;
int counts = 0;
int B;
int nexts;
void dfs(int x, int val, int S)
{
if (counts >= S)
{
nexts = x;
return;
}
if (ret[x] != 3)
return;
ret[x] = val;
counts++;
for (auto i : adj[x])
dfs(i, val);
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q)
{
B = b;
adj.resize(n);
ret.resize(n, 3);
FOR(i, 0, p.size())
{
adj[p[i]].push_back(q[i]);
adj[q[i]].push_back(p[i]);
}
int end = 0;
FOR(i, 0, n)
{
if (adj[i].size() == 1)
{
end = i;
break;
}
}
dfs(end, 1,a);
dfs(nexts, 2, b);
return ret;
}