# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
157935 | PeppaPig | Cat in a tree (BOI17_catinatree) | C++14 | 254 ms | 40720 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int n, k;
int dep[N], hv[N];
vector<int> g[N];
multiset<int> S[N];
int dfs(int u, int p) {
dep[u] = dep[p] + 1;
int sz = 1, mx = 0, x = -1;
for(int v : g[u]) if(v != p) {
int z = dfs(v, u);
if(z > mx) mx = z, x = v;
sz += z;
}
hv[u] = x;
return sz;
}
void sack(int u, int p) {
S[u].emplace(dep[u]);
for(int v : g[u]) if(v != p) sack(v, u);
if(hv[u] == -1) return;
swap(S[u], S[hv[u]]);
for(int v : g[u]) if(v != p) {
while(!S[u].empty() && !S[v].empty() && *S[u].begin() + *S[v].begin() - 2 * dep[u] < k) {
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |