#include <bits/stdc++.h>
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
int main() {
FastIO;
ll i, ans, N, K, Q, P, S;
cin >> N >> K >> Q;
vector<ll> D(N + 1);
D[1] = 0;
for(i = 2; i <= N; i++) {
cin >> P;
D[i] = D[P] + 1;
}
while(Q--) {
cin >> ans;
for(i = 2; i <= N; i++) {
cin >> S;
ans ^= S & ((D[i] + K - 1) & (K - 1));
}
cout << ans << '\n';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2060 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 3ms | 2152 KiB | ||||
4 | Wrong answer | 19ms | 3032 KiB | ||||
5 | Accepted | 50ms | 5616 KiB | ||||
subtask3 | 0/10 | ||||||
6 | Wrong answer | 3ms | 4340 KiB | ||||
7 | Wrong answer | 3ms | 4684 KiB | ||||
8 | Wrong answer | 3ms | 4600 KiB | ||||
9 | Wrong answer | 3ms | 4684 KiB | ||||
10 | Wrong answer | 3ms | 4952 KiB | ||||
subtask4 | 0/30 | ||||||
11 | Wrong answer | 14ms | 5192 KiB | ||||
12 | Wrong answer | 14ms | 5760 KiB | ||||
13 | Wrong answer | 14ms | 6084 KiB | ||||
14 | Accepted | 16ms | 6668 KiB | ||||
15 | Wrong answer | 14ms | 6932 KiB | ||||
16 | Wrong answer | 16ms | 7408 KiB | ||||
17 | Wrong answer | 14ms | 7884 KiB | ||||
subtask5 | 0/45 | ||||||
18 | Wrong answer | 46ms | 9156 KiB | ||||
19 | Wrong answer | 46ms | 10232 KiB | ||||
20 | Wrong answer | 46ms | 11280 KiB | ||||
21 | Wrong answer | 46ms | 12396 KiB | ||||
22 | Wrong answer | 46ms | 13788 KiB | ||||
23 | Wrong answer | 54ms | 16340 KiB | ||||
24 | Wrong answer | 54ms | 17864 KiB | ||||
25 | Wrong answer | 56ms | 19720 KiB | ||||
26 | Wrong answer | 54ms | 21244 KiB | ||||
27 | Wrong answer | 54ms | 22800 KiB | ||||
28 | Wrong answer | 41ms | 22544 KiB | ||||
29 | Wrong answer | 41ms | 23532 KiB |