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;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 2e5+5;
const ll INF = 1e9+7;
vector<vector<ll>>adj(MAXN);
int order[MAXN];
void dfs(ll node, ll p, ll ind){
order[ind]=node;
for(auto u:adj[node]){
if(u==p)continue;
dfs(u,node,ind+1);
}
}
vector<int> find_split(int n,int a,int b,int c,vector<int>p,vector<int> q) {
int i,m=p.size();
vector<int> res(n);
int deg[n+1];
for(i=0;i<m;i++){
deg[i]=0;
}
for(i=0;i<m;i++){
deg[p[i]]++;
deg[q[i]]++;
}
bool ok=false;
for(i=0;i<n;i++){
if(deg[i]==1){//cout<<"hihi";
ok=true; break;
}
}
for(i=1;i<m;i++){
adj[p[i]].pb(q[i]);
adj[q[i]].pb(p[i]);
}
if(ok==true){i=0;
adj[p[i]].pb(q[i]);
adj[q[i]].pb(p[i]);
}else{
deg[p[0]]--; deg[q[0]]--;
}
for(i=0;i<n;i++){
if(deg[i]==1){
ok=true; break;
}
}
dfs(i,-1,0);
for(i=0;i<a;i++)res[order[i]]=1;
for(i=a;i<a+b;i++)res[order[i]]=2;
for(i=a+b;i<n;i++)res[order[i]]=3;
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... |