55472023-07-22 20:27:06gortomiLámpákcpp17Wrong answer 0/10064ms21576 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
1Wrong answer3ms2040 KiB
2Accepted3ms2248 KiB
subtask20/15
3Wrong answer3ms2480 KiB
4Wrong answer18ms3376 KiB
5Accepted50ms9504 KiB
subtask30/10
6Wrong answer3ms2896 KiB
7Wrong answer3ms2876 KiB
8Wrong answer3ms3008 KiB
9Wrong answer3ms3092 KiB
10Wrong answer3ms3096 KiB
subtask40/30
11Accepted14ms3300 KiB
12Accepted14ms3284 KiB
13Wrong answer14ms3504 KiB
14Wrong answer14ms3860 KiB
15Wrong answer14ms3928 KiB
16Wrong answer14ms4148 KiB
17Wrong answer14ms4164 KiB
subtask50/45
18Wrong answer48ms6092 KiB
19Wrong answer46ms6864 KiB
20Wrong answer48ms6732 KiB
21Wrong answer46ms8444 KiB
22Wrong answer46ms8372 KiB
23Accepted64ms13008 KiB
24Wrong answer63ms15344 KiB
25Wrong answer63ms15496 KiB
26Wrong answer63ms21476 KiB
27Wrong answer64ms21576 KiB
28Wrong answer41ms5504 KiB
29Wrong answer39ms5588 KiB