#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second
const int maxn = 100;
int n, k, q;
int par[1 + maxn];
int state[1 + maxn];
int subtreexor[1 + maxn];
void solve() {
cin >> n >> k >> q;
for(int i = 2; i <= n; i++) {
cin >> par[i];
}
for(int qi = 1; qi <= q; qi++) {
for(int i = 1; i <= n; i++) {
cin >> state[i];
}
for(int j = 1; j <= k; j++) {
for(int i = 1; i <= n; i++) {
subtreexor[i] = 0;
}
for(int i = n; i >= 1; i--) {
int prevxor = subtreexor[i];
subtreexor[i] ^= state[i];
state[i] ^= prevxor;
subtreexor[par[i]] ^= subtreexor[i];
}
}
cout << state[1] << "\n";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1772 KiB | ||||
2 | Accepted | 3ms | 1928 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Time limit exceeded | 1.1s | 1996 KiB | ||||
4 | Wrong answer | 3ms | 2512 KiB | ||||
5 | Wrong answer | 3ms | 2600 KiB | ||||
subtask3 | 10/10 | ||||||
6 | Accepted | 6ms | 2688 KiB | ||||
7 | Accepted | 7ms | 2664 KiB | ||||
8 | Accepted | 4ms | 2884 KiB | ||||
9 | Accepted | 4ms | 2988 KiB | ||||
10 | Accepted | 3ms | 3068 KiB | ||||
subtask4 | 0/30 | ||||||
11 | Time limit exceeded | 1.098s | 3260 KiB | ||||
12 | Time limit exceeded | 1.046s | 3368 KiB | ||||
13 | Time limit exceeded | 1.07s | 3320 KiB | ||||
14 | Time limit exceeded | 1.062s | 3412 KiB | ||||
15 | Time limit exceeded | 1.057s | 3520 KiB | ||||
16 | Time limit exceeded | 1.037s | 3328 KiB | ||||
17 | Time limit exceeded | 1.062s | 3472 KiB | ||||
subtask5 | 0/45 | ||||||
18 | Wrong answer | 4ms | 3604 KiB | ||||
19 | Wrong answer | 6ms | 3816 KiB | ||||
20 | Wrong answer | 6ms | 3916 KiB | ||||
21 | Wrong answer | 7ms | 3988 KiB | ||||
22 | Wrong answer | 7ms | 4076 KiB | ||||
23 | Wrong answer | 4ms | 4076 KiB | ||||
24 | Wrong answer | 4ms | 4084 KiB | ||||
25 | Wrong answer | 4ms | 3992 KiB | ||||
26 | Wrong answer | 7ms | 3984 KiB | ||||
27 | Wrong answer | 7ms | 3984 KiB | ||||
28 | Wrong answer | 4ms | 3988 KiB | ||||
29 | Wrong answer | 4ms | 4076 KiB |