# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
30884 |
2017-07-30T10:47:50 Z |
cgiosy |
None (KOI16_tree) |
C++14 |
|
9 ms |
12960 KB |
#include <bits/stdc++.h>
using namespace std;
int n, 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; i < q; i++)
{
cin >> b >> c >> d;
x = (t[b].r == t[c].r);
puts(x ? "YES" : "NO");
if(x)
{
k = d ? b : c;
t[k].c.erase(t[k].p);
f(k);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
12960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
12960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
12960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
12960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
12960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |