#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> d;
void dfs(int n, int dep)
{
d[n] = dep;
for(auto x : g[n]) dfs(x, dep + 1);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, k, q;
cin >> n >> k >> q;
g.resize(n + 1);
d.resize(n + 1);
for(int i = 2; i <= n; i++)
{
int x;
cin >> x;
g[x].push_back(i);
}
dfs(1, 0);
while(q--)
{
int ans = 0;
for(int i = 1; i <= n; i++)
{
int x;
cin >> x;
if(d[i] & k == d[i]) ans ^= x;
}
cout << ans << "\n";
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1892 KiB | ||||
2 | Wrong answer | 3ms | 2008 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 3ms | 2252 KiB | ||||
4 | Wrong answer | 18ms | 3176 KiB | ||||
5 | Wrong answer | 52ms | 9332 KiB | ||||
subtask3 | 0/10 | ||||||
6 | Wrong answer | 3ms | 3012 KiB | ||||
7 | Wrong answer | 3ms | 3212 KiB | ||||
8 | Wrong answer | 3ms | 3428 KiB | ||||
9 | Wrong answer | 3ms | 3640 KiB | ||||
10 | Wrong answer | 3ms | 3732 KiB | ||||
subtask4 | 0/30 | ||||||
11 | Wrong answer | 14ms | 3532 KiB | ||||
12 | Wrong answer | 14ms | 3736 KiB | ||||
13 | Wrong answer | 14ms | 3820 KiB | ||||
14 | Wrong answer | 14ms | 3820 KiB | ||||
15 | Wrong answer | 14ms | 3780 KiB | ||||
16 | Wrong answer | 14ms | 3692 KiB | ||||
17 | Wrong answer | 14ms | 3692 KiB | ||||
subtask5 | 0/45 | ||||||
18 | Wrong answer | 46ms | 5884 KiB | ||||
19 | Wrong answer | 46ms | 6348 KiB | ||||
20 | Wrong answer | 46ms | 6408 KiB | ||||
21 | Wrong answer | 46ms | 7900 KiB | ||||
22 | Wrong answer | 46ms | 8156 KiB | ||||
23 | Wrong answer | 64ms | 13040 KiB | ||||
24 | Wrong answer | 61ms | 15204 KiB | ||||
25 | Wrong answer | 64ms | 15448 KiB | ||||
26 | Wrong answer | 63ms | 21304 KiB | ||||
27 | Wrong answer | 61ms | 21080 KiB | ||||
28 | Wrong answer | 39ms | 5020 KiB | ||||
29 | Wrong answer | 39ms | 5252 KiB |