104002024-04-01 19:43:10Valaki2Lámpákcpp17Time limit exceeded 10/1001.1s4084 KiB
#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();
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1772 KiB
2Accepted3ms1928 KiB
subtask20/15
3Time limit exceeded1.1s1996 KiB
4Wrong answer3ms2512 KiB
5Wrong answer3ms2600 KiB
subtask310/10
6Accepted6ms2688 KiB
7Accepted7ms2664 KiB
8Accepted4ms2884 KiB
9Accepted4ms2988 KiB
10Accepted3ms3068 KiB
subtask40/30
11Time limit exceeded1.098s3260 KiB
12Time limit exceeded1.046s3368 KiB
13Time limit exceeded1.07s3320 KiB
14Time limit exceeded1.062s3412 KiB
15Time limit exceeded1.057s3520 KiB
16Time limit exceeded1.037s3328 KiB
17Time limit exceeded1.062s3472 KiB
subtask50/45
18Wrong answer4ms3604 KiB
19Wrong answer6ms3816 KiB
20Wrong answer6ms3916 KiB
21Wrong answer7ms3988 KiB
22Wrong answer7ms4076 KiB
23Wrong answer4ms4076 KiB
24Wrong answer4ms4084 KiB
25Wrong answer4ms3992 KiB
26Wrong answer7ms3984 KiB
27Wrong answer7ms3984 KiB
28Wrong answer4ms3988 KiB
29Wrong answer4ms4076 KiB