# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
297887 | juggernaut | Split the Attractions (IOI19_split) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include"split.h"
using namespace std;
vector<int>g[100005];
int ans[100005];
int fir(int v,int p){
for(int to:g[v])if(to!=p)return fir(to,v);
return v;
}
vector<int>find_split(int n,int a,int b,int c,vector<int>p1,vector<int>p2){
int root=0;
for(int i=0;i<p1.size();i++){
g[p1[i]].push_back(p2[i]);
g[p2[i]].push_back(p1[i]);
}
if(i!=n)root=fir(root,-1);
while(a--){
ans[root]=1;
for(int to:g[v])if(!ans[to])root=to;
}
while(b--){
ans[root]=2;
for(int to:g[v])if(!ans[to])root=to;
}
while(c--){
ans[root]=3;
for(int to:g[v])if(!ans[to])root=to;
}
vector<int>res;
for(int i=0;i<n;i++)res.push_back(ans[i]);
return res;
}