이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |