55382023-07-13 21:02:19111Lámpákcpp14Wrong answer 55/10093ms26688 KiB
#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 %= 32;
	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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1816 KiB
2Accepted3ms2044 KiB
subtask215/15
3Accepted3ms2416 KiB
4Accepted6ms4148 KiB
5Accepted29ms8996 KiB
subtask310/10
6Accepted3ms4608 KiB
7Accepted3ms4700 KiB
8Accepted3ms4616 KiB
9Accepted3ms4624 KiB
10Accepted3ms4644 KiB
subtask430/30
11Accepted12ms5712 KiB
12Accepted8ms5980 KiB
13Accepted14ms6528 KiB
14Accepted8ms7068 KiB
15Accepted16ms7316 KiB
16Accepted13ms7536 KiB
17Accepted29ms8088 KiB
subtask50/45
18Accepted34ms11680 KiB
19Wrong answer61ms12840 KiB
20Wrong answer41ms13952 KiB
21Wrong answer41ms15008 KiB
22Wrong answer45ms16124 KiB
23Accepted46ms20408 KiB
24Wrong answer41ms22072 KiB
25Wrong answer93ms23604 KiB
26Wrong answer25ms25152 KiB
27Wrong answer48ms26688 KiB
28Wrong answer65ms24528 KiB
29Wrong answer61ms25512 KiB