이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "split.h"
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int) 1e5+5
vector<int> ad[MAX_N];
vector<int> res;
vector<bool> vis(MAX_N,0);
vector<pair<int,int>> cnt;
int tiefe = 0;
void dfs(int x,int e){
if(vis[x]) return;
vis[x] = 1;
if(tiefe < cnt[0].first)
res[x] = cnt[0].second;
else if(tiefe >= cnt[0].first && tiefe < cnt[0].first+cnt[1].first)
res[x] = cnt[1].second;
else return;
++tiefe;
for(auto s: ad[x]){
if(vis[s]) continue;
dfs(s,x);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
for(int i = 0;i<(int)p.size();i++){
ad[p[i]].push_back(q[i]);
ad[q[i]].push_back(p[i]);
}
res.assign(n,0);
if(a >= n-1 || b >= n-1 || c>=n-1 || (int)p.size() < n - 1) return res;
cnt.push_back({a,1});
cnt.push_back({b,2});
cnt.push_back({c,3});
sort(cnt.begin(),cnt.end());
for(int i = 0;i<n;i++){
tiefe = 0;
res.assign(n,cnt[2].second);
dfs(i,-1);
vis.clear();
if(cnt[0].first+cnt[1].first == tiefe) return res;
}
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... |