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 MX = 2e5 + 5;
vector<int> adj[MX];
void dfs(int i, vector<int> &vis, vector<int> &path)
{
vis[i] = 1;
path.push_back(i);
for(int j:adj[i])
if(!vis[j])
dfs(j, vis, path);
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q)
{
int m = p.size();
for(int i=0;i<m;i++)
{
adj[p[i]].push_back(q[i]);
adj[q[i]].push_back(p[i]);
}
int root = -1;
for(int i=0;i<n;i++)
{
if(adj[i].size() == 1)
{
root = i;
break;
}
}
root = max(root, 0);
vector<int> vis(n, 0), path, res(n, 3);
dfs(root, vis, path);
for(int i=0;i<a;i++)
res[path[i]] = 1;
for(int i=a;i<a+b;i++)
res[path[i]] = 2;
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... |