이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "split.h"
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 2e5;
vector <int> v[MAXN];
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
int m = p.size(), mx = 0;
for(int i = 0; i < m; i++){
v[p[i]].push_back(q[i]);
v[q[i]].push_back(p[i]);
mx = max(mx, (int)v[p[i]].size());
mx = max(mx, (int)v[q[i]].size());
}
vector <int> res(n);
if(mx < 3){
int F = 0, Last = 0;
for(int i = 0; i < n; i++)if(v[i].size() == 1)F = i;
int step = 1;
vector <int> cnt(3);
cnt[0] = a;
cnt[1] = b;
cnt[2] = c;
for(int i = 0; i < n; i++){
if(i){
int New = 0;
for(auto j : v[F])if(j != Last)New = j;
Last = F;
F = New;
}
while(!cnt[step - 1])step++;
--cnt[step - 1];
res[F] = step;
}
return res;
}else if(a == 1){
queue <int> q;
res[0] = 1;
q.push(0);
vector <bool> f(n);
f[0] = 1;
while(!q.empty()){
int x = q.front();
if(!b)break;
b--;
res[x] = 2;
for(auto to : v[x])if(!f[to]){
f[to] = 1;
q.push(to);
}
}
for(auto &i : res)if(!i)i = 3;
return res;
}else{
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... |