55462023-07-22 20:14:23gortomiLámpákcpp17Wrong answer 0/10064ms21304 KiB
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> d;
void dfs(int n, int dep)
{
    d[n] = dep;
    for(auto x : g[n]) dfs(x, dep + 1);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k, q;
    cin >> n >> k >> q;
    g.resize(n + 1);
    d.resize(n + 1);
    for(int i = 2; i <= n; i++)
    {
        int x;
        cin >> x;
        g[x].push_back(i);
    }
    dfs(1, 0);
    while(q--)
    {
        int ans = 0;
        for(int i = 1; i <= n; i++)
        {
            int x;
            cin >> x;
            if(d[i] & k == d[i]) ans ^= x;
        }
        cout << ans << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1892 KiB
2Wrong answer3ms2008 KiB
subtask20/15
3Wrong answer3ms2252 KiB
4Wrong answer18ms3176 KiB
5Wrong answer52ms9332 KiB
subtask30/10
6Wrong answer3ms3012 KiB
7Wrong answer3ms3212 KiB
8Wrong answer3ms3428 KiB
9Wrong answer3ms3640 KiB
10Wrong answer3ms3732 KiB
subtask40/30
11Wrong answer14ms3532 KiB
12Wrong answer14ms3736 KiB
13Wrong answer14ms3820 KiB
14Wrong answer14ms3820 KiB
15Wrong answer14ms3780 KiB
16Wrong answer14ms3692 KiB
17Wrong answer14ms3692 KiB
subtask50/45
18Wrong answer46ms5884 KiB
19Wrong answer46ms6348 KiB
20Wrong answer46ms6408 KiB
21Wrong answer46ms7900 KiB
22Wrong answer46ms8156 KiB
23Wrong answer64ms13040 KiB
24Wrong answer61ms15204 KiB
25Wrong answer64ms15448 KiB
26Wrong answer63ms21304 KiB
27Wrong answer61ms21080 KiB
28Wrong answer39ms5020 KiB
29Wrong answer39ms5252 KiB