#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 | Wrong answer | 3ms | 2040 KiB | ||||
2 | Accepted | 3ms | 2248 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 3ms | 2480 KiB | ||||
4 | Wrong answer | 18ms | 3376 KiB | ||||
5 | Accepted | 50ms | 9504 KiB | ||||
subtask3 | 0/10 | ||||||
6 | Wrong answer | 3ms | 2896 KiB | ||||
7 | Wrong answer | 3ms | 2876 KiB | ||||
8 | Wrong answer | 3ms | 3008 KiB | ||||
9 | Wrong answer | 3ms | 3092 KiB | ||||
10 | Wrong answer | 3ms | 3096 KiB | ||||
subtask4 | 0/30 | ||||||
11 | Accepted | 14ms | 3300 KiB | ||||
12 | Accepted | 14ms | 3284 KiB | ||||
13 | Wrong answer | 14ms | 3504 KiB | ||||
14 | Wrong answer | 14ms | 3860 KiB | ||||
15 | Wrong answer | 14ms | 3928 KiB | ||||
16 | Wrong answer | 14ms | 4148 KiB | ||||
17 | Wrong answer | 14ms | 4164 KiB | ||||
subtask5 | 0/45 | ||||||
18 | Wrong answer | 48ms | 6092 KiB | ||||
19 | Wrong answer | 46ms | 6864 KiB | ||||
20 | Wrong answer | 48ms | 6732 KiB | ||||
21 | Wrong answer | 46ms | 8444 KiB | ||||
22 | Wrong answer | 46ms | 8372 KiB | ||||
23 | Accepted | 64ms | 13008 KiB | ||||
24 | Wrong answer | 63ms | 15344 KiB | ||||
25 | Wrong answer | 63ms | 15496 KiB | ||||
26 | Wrong answer | 63ms | 21476 KiB | ||||
27 | Wrong answer | 64ms | 21576 KiB | ||||
28 | Wrong answer | 41ms | 5504 KiB | ||||
29 | Wrong answer | 39ms | 5588 KiB |