이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "split.h"
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define loop(x, i) for (int i = 0; i < x; i++)
#define rev(x, i) for (int i = (int)x - 1; i >= 0; i--)
#define ALL(x) begin(x), end(x)
typedef signed i32;
typedef pair<int, int> ii;
typedef vector<i32> vi32;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vb> vvb;
vi find_split(int n, int a, int b, int c, vi p, vi q)
{
vii prts = {{a, 1}, {b, 2}, {c, 3}};
sort(ALL(prts));
int A = prts[0].first, B = prts[1].first, C = prts[2].first;
int aix = prts[0].second, bix = prts[1].second, cix = prts[2].second;
vvi adj(n);
int m = sz(p);
loop(m, i)
{
adj[p[i]].pb(q[i]);
adj[q[i]].pb(p[i]);
}
vi res(n);
auto dfs = [&](auto &&self, int i, int prev, int cnt) -> void
{
if (cnt < A)
res[i] = aix;
else if (cnt < A + B)
res[i] = bix;
else
res[i] = cix;
for (int j : adj[i])
{
if (j == prev)
continue;
self(self, j, i, cnt + 1);
}
};
loop(n, i)
{
if (adj[i].size() == 1)
{
dfs(dfs, i, i, 0);
break;
}
}
assert(*max_element(ALL(res)) != 0);
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
split.cpp: In function 'vi find_split(int, int, int, int, vi, vi)':
split.cpp:24:44: warning: unused variable 'C' [-Wunused-variable]
24 | int A = prts[0].first, B = prts[1].first, C = prts[2].first;
| ^
# | 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... |