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>
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
struct node
{
vector<int> edges;
bool been;
};
vector<int> res;
vector<int> order;
vector<node> g;
int A, B, C;
void dfs(int n)
{
if (g[n].been)
return;
order.push_back(n);
g[n].been = true;
for (int i : g[n].edges)
dfs(i);
return;
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q)
{
A = a, B = b, C = c;
g.resize(n);
res.resize(n);
for (int i = 0; i < n; i++)
{
g[p[i]].edges.push_back(q[i]);
g[q[i]].edges.push_back(p[i]);
}
int stp = 0;
for (stp = 0; stp < n; stp++)
{
if (g[stp].edges.size() == 1)
{
dfs(stp);
break;
}
}
if (stp == n)
dfs(0);
stp = 0;
while (a--)
{
res[order[stp]] = 1;
stp++;
}
while (b--)
{
res[order[stp]] = 2;
stp++;
}
while (c--)
{
res[order[stp]] = 3;
stp++;
}
return res;
}
# | 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... |