#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 %= 256;
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 | 2040 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 6ms | 2292 KiB | ||||
4 | Accepted | 50ms | 3492 KiB | ||||
5 | Accepted | 56ms | 7288 KiB | ||||
subtask3 | 10/10 | ||||||
6 | Accepted | 3ms | 2920 KiB | ||||
7 | Accepted | 3ms | 2996 KiB | ||||
8 | Accepted | 3ms | 3096 KiB | ||||
9 | Accepted | 4ms | 3124 KiB | ||||
10 | Accepted | 4ms | 3332 KiB | ||||
subtask4 | 30/30 | ||||||
11 | Accepted | 52ms | 3964 KiB | ||||
12 | Accepted | 54ms | 4220 KiB | ||||
13 | Accepted | 37ms | 4308 KiB | ||||
14 | Accepted | 39ms | 4624 KiB | ||||
15 | Accepted | 16ms | 4588 KiB | ||||
16 | Accepted | 50ms | 4588 KiB | ||||
17 | Accepted | 78ms | 4584 KiB | ||||
subtask5 | 0/45 | ||||||
18 | Accepted | 172ms | 6764 KiB | ||||
19 | Wrong answer | 239ms | 6832 KiB | ||||
20 | Wrong answer | 307ms | 6836 KiB | ||||
21 | Wrong answer | 763ms | 6916 KiB | ||||
22 | Wrong answer | 647ms | 6944 KiB | ||||
23 | Accepted | 254ms | 9340 KiB | ||||
24 | Wrong answer | 129ms | 9768 KiB | ||||
25 | Wrong answer | 273ms | 9968 KiB | ||||
26 | Wrong answer | 388ms | 10216 KiB | ||||
27 | Wrong answer | 777ms | 10116 KiB | ||||
28 | Wrong answer | 324ms | 7204 KiB | ||||
29 | Wrong answer | 236ms | 7160 KiB |