55392023-07-13 21:03:08111Lámpákcpp14Wrong answer 55/100777ms10216 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 %= 256;
	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
2Accepted3ms2040 KiB
subtask215/15
3Accepted6ms2292 KiB
4Accepted50ms3492 KiB
5Accepted56ms7288 KiB
subtask310/10
6Accepted3ms2920 KiB
7Accepted3ms2996 KiB
8Accepted3ms3096 KiB
9Accepted4ms3124 KiB
10Accepted4ms3332 KiB
subtask430/30
11Accepted52ms3964 KiB
12Accepted54ms4220 KiB
13Accepted37ms4308 KiB
14Accepted39ms4624 KiB
15Accepted16ms4588 KiB
16Accepted50ms4588 KiB
17Accepted78ms4584 KiB
subtask50/45
18Accepted172ms6764 KiB
19Wrong answer239ms6832 KiB
20Wrong answer307ms6836 KiB
21Wrong answer763ms6916 KiB
22Wrong answer647ms6944 KiB
23Accepted254ms9340 KiB
24Wrong answer129ms9768 KiB
25Wrong answer273ms9968 KiB
26Wrong answer388ms10216 KiB
27Wrong answer777ms10116 KiB
28Wrong answer324ms7204 KiB
29Wrong answer236ms7160 KiB