55552023-07-25 13:49:38AndrosLámpákcpp17Wrong answer 0/1001.1s129636 KiB
#include <iostream>
#include <bitset>
#include <vector>

#define maxN 100010

using namespace std;

int megelozesek[maxN];

vector<int> alatta[maxN];
vector<int> felette[maxN];

int main()
{
	int n, k, q;
	cin >> n >> k >> q;

	for (int u = 2; u <= n; u++)//v<-u: v-nek jelez u
	{
		int v;
		cin >> v;
		alatta[u] = alatta[v];//Aminek jelez v, annak jelez u is
		alatta[u].push_back(v);//v-nek is jelez u
		felette[v].push_back(u);//v kap jelet u-tol
		for (int elem : alatta[v]) {//minden torony, aminek v jelet kuld, kap jelet u-tol
			felette[elem].push_back(u);
		}
	}

	vector<bool> mo;
	bitset<maxN> allapot=0b0;
	int a;
	for (int i = 1; i <= q; i++)//tesztek szama
	{
		
		for (int p = 1; p <= n; p++)
		{
			cin >> a;
			allapot[p] = a;//Kezdoallapot felvetele
		}

		for (int o = 0; o < k; o++)//Probak szama
		{
			for (int j = 1; j <= n; j++)//Ha paratlan bekapcsolt van felette, akkor atkapcsol az allapota
			{
				int cc = 0;
				for (int elem : felette[i]) {
					if (allapot[elem]){//Bekapcsoltak szama
						cc++;//Ez lehetne egy allapot[i].flip() is
					}
				}
				if (cc % 2 == 1) {
					allapot[i].flip();
				}
			}
		}

		mo.push_back(allapot[1]);
	}

	for (int elem : mo) {
		cout << elem << endl;
	}

}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted6ms11248 KiB
2Wrong answer6ms11512 KiB
subtask20/15
3Time limit exceeded1.1s6304 KiB
4Time limit exceeded1.074s6888 KiB
5Time limit exceeded1.046s10680 KiB
subtask30/10
6Wrong answer48ms12360 KiB
7Wrong answer52ms12424 KiB
8Wrong answer57ms12704 KiB
9Wrong answer39ms12784 KiB
10Wrong answer46ms13040 KiB
subtask40/30
11Time limit exceeded1.057s7672 KiB
12Time limit exceeded1.049s7872 KiB
13Time limit exceeded1.026s7888 KiB
14Time limit exceeded1.042s7904 KiB
15Time limit exceeded1.057s7844 KiB
16Time limit exceeded1.06s7828 KiB
17Time limit exceeded1.074s7724 KiB
subtask50/45
18Time limit exceeded1.082s11388 KiB
19Runtime error86ms129636 KiB
20Runtime error86ms129612 KiB
21Runtime error112ms129580 KiB
22Runtime error114ms129552 KiB
23Time limit exceeded1.075s25160 KiB
24Runtime error86ms129552 KiB
25Runtime error86ms129420 KiB
26Runtime error97ms129416 KiB
27Runtime error96ms129392 KiB
28Time limit exceeded1.067s62068 KiB
29Time limit exceeded1.064s60508 KiB