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 "bits/stdc++.h"
#include "split.h"
using namespace std;
#define ll long long
#define pb push_back
void dfs(vector<int> adj[], vector<bool> &visited, int u, vector<int> &res)
{
res.pb(u);
visited[u] = true;
for(auto v: adj[u])
{
if(!visited[v])
{
dfs(adj, visited, v, res);
}
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int>q)
{
vector<int> adj[n];
int m = (int)p.size();
for(int i = 0; i<m; i++)
{
adj[p[i]].pb(q[i]);
adj[q[i]].pb(p[i]);
}
vector<int> res;
vector<bool> visited(n, false);
int beg = 0;
for(int i = 0; i<n; i++)
{
if((int)adj[i].size()==1)
{
beg = i;
break;
}
}
dfs(adj, visited, beg, res);
vector<int> r(n, 0);
int i = 0;
int counter = 0;
while(counter<a)
{
r[res[i]] = 1;
i++, counter++;
}
counter = 0;
while(counter<b)
{
r[res[i]] = 2;
i++, counter++;
}
counter = 0;
while(counter<c)
{
r[res[i]] = 3;
i++, counter++;
}
return r;
}
# | 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... |