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