# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
730736 | danikoynov | Split the Attractions (IOI19_split) | C++14 | 80 ms | 14452 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 "split.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int deg[maxn], m, n;
vector < int > graph[maxn];
int used[maxn];
vector < int > order;
void stick(int v)
{
used[v] = 1;
order.push_back(v);
for (int u : graph[v])
{
if (!used[u])
stick(u);
}
}
vector<int> find_split(int N, int a, int b, int c, vector<int> p, vector<int> q)
{
n = N;
m = p.size();
for (int i = 0; i < p.size(); i ++)
{
graph[p[i]].push_back(q[i]);
graph[q[i]].push_back(p[i]);
}
bool deg2 = true;
for (int i = 0; i < m; i ++)
{
if (graph[i].size() > 2)
{
deg2 = false;
break;
}
}
int leaf = 0;
while(leaf < n && graph[leaf].size() != 1)
leaf ++;
if (leaf == n)
leaf = 0;
stick(leaf);
if (deg2)
{
vector < int > res(n);
for (int i = 0; i < n; i ++)
{
int v = order[i];
if (i < a)
res[v] = 1;
else
if (i < a + b)
res[v] = 2;
else
res[v] = 3;
}
return res;
}
else
{
vector < int > tmp;
return tmp;
}
}
Compilation message (stderr)
# | 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... |