#include <iostream>
#include <vector>
using namespace std;
int n, k, q;
vector<int> p(1e5 + 1, 0);
vector<int> d(1e5 + 1, 0);
int binomial(int a, int b){
if (!b) return 1;
if (!(a % 2) && b % 2) return 0;
return binomial(a / 2, b / 2);
}
void query(){
int a, ans = 0;
for (int i = 1; i <= n; i++){
cin >> a;
if (a) ans += binomial(d[i] + k - 1, d[i]);
}
cout << ans % 2 << endl;
}
int main(){
cin >> n >> k >> q;
for (int i = 2; i <= n; i++){
cin >> p[i];
d[i] = d[p[i]] + 1;
}
for (int i = 0; i < q; i++) query();
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 3168 KiB | ||||
2 | Accepted | 3ms | 3384 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 4ms | 3596 KiB | ||||
4 | Accepted | 41ms | 3812 KiB | ||||
5 | Accepted | 109ms | 4152 KiB | ||||
subtask3 | 10/10 | ||||||
6 | Accepted | 4ms | 4232 KiB | ||||
7 | Accepted | 3ms | 4292 KiB | ||||
8 | Accepted | 4ms | 4388 KiB | ||||
9 | Accepted | 3ms | 4292 KiB | ||||
10 | Accepted | 4ms | 4416 KiB | ||||
subtask4 | 30/30 | ||||||
11 | Accepted | 43ms | 4508 KiB | ||||
12 | Accepted | 48ms | 4728 KiB | ||||
13 | Accepted | 46ms | 4988 KiB | ||||
14 | Accepted | 48ms | 5332 KiB | ||||
15 | Accepted | 52ms | 5128 KiB | ||||
16 | Accepted | 43ms | 5132 KiB | ||||
17 | Accepted | 50ms | 5228 KiB | ||||
subtask5 | 45/45 | ||||||
18 | Accepted | 104ms | 5212 KiB | ||||
19 | Accepted | 108ms | 5212 KiB | ||||
20 | Accepted | 104ms | 5200 KiB | ||||
21 | Accepted | 111ms | 5192 KiB | ||||
22 | Accepted | 105ms | 5192 KiB | ||||
23 | Accepted | 126ms | 5204 KiB | ||||
24 | Accepted | 130ms | 5384 KiB | ||||
25 | Accepted | 128ms | 5328 KiB | ||||
26 | Accepted | 129ms | 5604 KiB | ||||
27 | Accepted | 130ms | 5524 KiB | ||||
28 | Accepted | 97ms | 5588 KiB | ||||
29 | Accepted | 97ms | 5716 KiB |