#include <bits/stdc++.h>
using namespace std;
char* pi = new char[10000000];
unsigned int ru() {
while (!isdigit(*pi)) {
pi++;
}
int x = 0;
while (isdigit(*pi)) {
x *= 10;
x += *pi - '0';
pi++;
}
return x;
}
int main() {
fread(pi, 10000000, 1, stdin);
// fread(pi, 10000000, 1, fopen("be2.txt", "r"));
int N = ru(), K = ru(), Q = ru();
K %= 32;
vector<int> v(N + 1);
for (int i = 2; i <= N; i++) {
v[i] = ru();
}
while (Q--) {
vector<int> w(N + 1);
for (int i = 1; i <= N; i++) {
w[i] = ru();
}
vector<int> u(N + 1);
for (int i = 1; i <= N; i++) {
u[v[i]] ^= w[i];
}
for (int k = 0; k < K; k++) {
for (int i = N; i >= 1; i--) {
if (u[i]) {
w[i] ^= 1;
u[v[i]] ^= 1;
}
}
}
cout << w[1] << '\n';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1816 KiB | ||||
2 | Accepted | 3ms | 2044 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 3ms | 2416 KiB | ||||
4 | Accepted | 6ms | 4148 KiB | ||||
5 | Accepted | 29ms | 8996 KiB | ||||
subtask3 | 10/10 | ||||||
6 | Accepted | 3ms | 4608 KiB | ||||
7 | Accepted | 3ms | 4700 KiB | ||||
8 | Accepted | 3ms | 4616 KiB | ||||
9 | Accepted | 3ms | 4624 KiB | ||||
10 | Accepted | 3ms | 4644 KiB | ||||
subtask4 | 30/30 | ||||||
11 | Accepted | 12ms | 5712 KiB | ||||
12 | Accepted | 8ms | 5980 KiB | ||||
13 | Accepted | 14ms | 6528 KiB | ||||
14 | Accepted | 8ms | 7068 KiB | ||||
15 | Accepted | 16ms | 7316 KiB | ||||
16 | Accepted | 13ms | 7536 KiB | ||||
17 | Accepted | 29ms | 8088 KiB | ||||
subtask5 | 0/45 | ||||||
18 | Accepted | 34ms | 11680 KiB | ||||
19 | Wrong answer | 61ms | 12840 KiB | ||||
20 | Wrong answer | 41ms | 13952 KiB | ||||
21 | Wrong answer | 41ms | 15008 KiB | ||||
22 | Wrong answer | 45ms | 16124 KiB | ||||
23 | Accepted | 46ms | 20408 KiB | ||||
24 | Wrong answer | 41ms | 22072 KiB | ||||
25 | Wrong answer | 93ms | 23604 KiB | ||||
26 | Wrong answer | 25ms | 25152 KiB | ||||
27 | Wrong answer | 48ms | 26688 KiB | ||||
28 | Wrong answer | 65ms | 24528 KiB | ||||
29 | Wrong answer | 61ms | 25512 KiB |