#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 & (1LL ^ (~(D[i] + K - 1) & D[i]));
}
cout << ans << '\n';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2028 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 3ms | 2112 KiB | ||||
4 | Accepted | 18ms | 2184 KiB | ||||
5 | Accepted | 50ms | 3700 KiB | ||||
subtask3 | 0/10 | ||||||
6 | Accepted | 3ms | 2444 KiB | ||||
7 | Wrong answer | 3ms | 2660 KiB | ||||
8 | Wrong answer | 3ms | 2752 KiB | ||||
9 | Wrong answer | 3ms | 2632 KiB | ||||
10 | Wrong answer | 3ms | 2860 KiB | ||||
subtask4 | 0/30 | ||||||
11 | Wrong answer | 14ms | 3220 KiB | ||||
12 | Wrong answer | 14ms | 3312 KiB | ||||
13 | Wrong answer | 14ms | 3308 KiB | ||||
14 | Accepted | 14ms | 3512 KiB | ||||
15 | Wrong answer | 14ms | 3728 KiB | ||||
16 | Wrong answer | 14ms | 3908 KiB | ||||
17 | Wrong answer | 14ms | 3992 KiB | ||||
subtask5 | 0/45 | ||||||
18 | Wrong answer | 45ms | 4148 KiB | ||||
19 | Wrong answer | 45ms | 4164 KiB | ||||
20 | Wrong answer | 45ms | 4112 KiB | ||||
21 | Wrong answer | 46ms | 4244 KiB | ||||
22 | Wrong answer | 45ms | 4232 KiB | ||||
23 | Wrong answer | 52ms | 5264 KiB | ||||
24 | Wrong answer | 52ms | 5264 KiB | ||||
25 | Wrong answer | 54ms | 5320 KiB | ||||
26 | Wrong answer | 54ms | 5640 KiB | ||||
27 | Wrong answer | 54ms | 5792 KiB | ||||
28 | Wrong answer | 41ms | 4496 KiB | ||||
29 | Wrong answer | 41ms | 4428 KiB |