# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
384843 | dolphingarlic | Pastiri (COI20_pastiri) | C++14 | 1097 ms | 107448 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> graph[500001];
int sheep[500001], to_sheep[500001], depth[500001], anc[500001][19], highest[500001];
bool guarded[500001];
void dfs(int node = 1, int parent = 0, int d = 0) {
depth[node] = d;
for (int i = 1; i < 19; i++) anc[node][i] = anc[anc[node][i - 1]][i - 1];
int h = node, dist = 1;
for (int i = 18; ~i; i--) if (dist + (1 << i) == to_sheep[anc[h][i]]) {
dist += (1 << i);
h = anc[h][i];
}
highest[node] = h;
for (int i : graph[node]) if (i != parent) {
anc[i][0] = node;
dfs(i, node, d + 1);
}
}
void guard(int node) {
guarded[node] = true;
for (int i : graph[node]) if (!guarded[i] && to_sheep[node] == to_sheep[i] + 1) guard(i);
}
# | 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... |