| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 30885 | cgiosy | 트리 (KOI16_tree) | C++14 | 26 ms | 12960 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, m, q, a, b, c, d, x, k;
struct {int p; int r; set<int> c;} t[200010];
void f(int i)
{
t[i].r = k;
for(int j : t[i].c)
f(j);
}
int main()
{
cin >> n >> q;
t[1].p = t[1].r = 1;
for(int i = 2; i <= n; i++)
{
cin >> a;
t[i].p = a;
t[i].r = 1;
t[a].c.insert(i);
}
for(int i = 0, m = n + q; i < q; i++)
{
cin >> b >> c >> d;
x = (t[b].r == t[c].r);
puts(x ? "YES" : "NO");
if(d)
{
k = x ? b : c;
t[k].c.erase(t[k].p);
f(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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
