답안 #1059904

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059904 2024-08-15T09:00:10 Z parsadox2 디지털 회로 (IOI22_circuit) C++17
46 / 100
3000 ms 7512 KB
#include <bits/stdc++.h>
#include "circuit.h"

using namespace std;

const int N = 2e5 + 10 , mod = 1000002022;
int sbt[N] , n , m , zarib[N];
vector <int> p , a , adj[N];

void Find_sbt(int v)
{
	sbt[v] = adj[v].size();
	if(sbt[v] == 0)
		sbt[v] = 1;
	for(auto u : adj[v])
	{
		Find_sbt(u);
		sbt[v] = 1LL * sbt[v] * sbt[u] % mod;
	}
}

void Add(int v , int val)
{
	if(v >= n)
	{
		zarib[v - n] = 1LL * zarib[v - n] * val % mod;
		return;
	}
	for(auto u : adj[v])
		Add(u , val);
}

void Dfs(int v)
{
	for(auto u : adj[v])  for(auto w : adj[v])  if(u != w)
		Add(w , sbt[u]);
	for(auto u : adj[v])
		Dfs(u);
}

void init(int nn , int mm , vector <int> pp , vector <int> aa)
{
	n = nn;
	m = mm;
	p = pp;
	a = aa;
	for(int i = 0 ; i < m ; i++)
		zarib[i] = 1;
	for(int i = 1 ; i < n + m ; i++)
		adj[p[i]].push_back(i);
	Find_sbt(0);
	Dfs(0);
	/*for(int i = 0 ; i < m ; i++)
		cout << a[i] << " " << zarib[i] << endl;
		*/
}

int count_ways(int l , int r)
{
	for(int i = l ; i <= r ; i++)
		a[i - n] ^= 1;
	int res = 0;
	for(int i = 0 ; i < m ; i++)  if(a[i] == 1)
	{
		res = (res + zarib[i]) % mod;
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 4 ms 4996 KB Output is correct
4 Correct 7 ms 4952 KB Output is correct
5 Correct 6 ms 5156 KB Output is correct
6 Correct 7 ms 4948 KB Output is correct
7 Correct 4 ms 4952 KB Output is correct
8 Correct 4 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4972 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 2 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 2 ms 5208 KB Output is correct
8 Correct 2 ms 5204 KB Output is correct
9 Correct 2 ms 5208 KB Output is correct
10 Correct 7 ms 5280 KB Output is correct
11 Correct 5 ms 5208 KB Output is correct
12 Correct 2 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 4 ms 4996 KB Output is correct
4 Correct 7 ms 4952 KB Output is correct
5 Correct 6 ms 5156 KB Output is correct
6 Correct 7 ms 4948 KB Output is correct
7 Correct 4 ms 4952 KB Output is correct
8 Correct 4 ms 4952 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4972 KB Output is correct
11 Correct 2 ms 4952 KB Output is correct
12 Correct 1 ms 4952 KB Output is correct
13 Correct 2 ms 4952 KB Output is correct
14 Correct 1 ms 4952 KB Output is correct
15 Correct 2 ms 5208 KB Output is correct
16 Correct 2 ms 5204 KB Output is correct
17 Correct 2 ms 5208 KB Output is correct
18 Correct 7 ms 5280 KB Output is correct
19 Correct 5 ms 5208 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 1 ms 4952 KB Output is correct
22 Correct 2 ms 4952 KB Output is correct
23 Correct 2 ms 4952 KB Output is correct
24 Correct 3 ms 5208 KB Output is correct
25 Correct 2 ms 5208 KB Output is correct
26 Correct 3 ms 5208 KB Output is correct
27 Correct 3 ms 5208 KB Output is correct
28 Correct 2 ms 5208 KB Output is correct
29 Correct 7 ms 4952 KB Output is correct
30 Correct 5 ms 4952 KB Output is correct
31 Correct 1 ms 5208 KB Output is correct
32 Correct 2 ms 5460 KB Output is correct
33 Correct 1 ms 4952 KB Output is correct
34 Correct 2 ms 4952 KB Output is correct
35 Correct 3 ms 4952 KB Output is correct
36 Correct 5 ms 5208 KB Output is correct
37 Correct 7 ms 5208 KB Output is correct
38 Correct 4 ms 5208 KB Output is correct
39 Correct 2 ms 4952 KB Output is correct
40 Correct 1 ms 5180 KB Output is correct
41 Correct 1 ms 4952 KB Output is correct
42 Correct 2 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3040 ms 7512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3040 ms 7512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4972 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 2 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 2 ms 5208 KB Output is correct
8 Correct 2 ms 5204 KB Output is correct
9 Correct 2 ms 5208 KB Output is correct
10 Correct 7 ms 5280 KB Output is correct
11 Correct 5 ms 5208 KB Output is correct
12 Correct 2 ms 4952 KB Output is correct
13 Execution timed out 3040 ms 7512 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 4 ms 4996 KB Output is correct
4 Correct 7 ms 4952 KB Output is correct
5 Correct 6 ms 5156 KB Output is correct
6 Correct 7 ms 4948 KB Output is correct
7 Correct 4 ms 4952 KB Output is correct
8 Correct 4 ms 4952 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4972 KB Output is correct
11 Correct 2 ms 4952 KB Output is correct
12 Correct 1 ms 4952 KB Output is correct
13 Correct 2 ms 4952 KB Output is correct
14 Correct 1 ms 4952 KB Output is correct
15 Correct 2 ms 5208 KB Output is correct
16 Correct 2 ms 5204 KB Output is correct
17 Correct 2 ms 5208 KB Output is correct
18 Correct 7 ms 5280 KB Output is correct
19 Correct 5 ms 5208 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 1 ms 4952 KB Output is correct
22 Correct 2 ms 4952 KB Output is correct
23 Correct 2 ms 4952 KB Output is correct
24 Correct 3 ms 5208 KB Output is correct
25 Correct 2 ms 5208 KB Output is correct
26 Correct 3 ms 5208 KB Output is correct
27 Correct 3 ms 5208 KB Output is correct
28 Correct 2 ms 5208 KB Output is correct
29 Correct 7 ms 4952 KB Output is correct
30 Correct 5 ms 4952 KB Output is correct
31 Correct 1 ms 5208 KB Output is correct
32 Correct 2 ms 5460 KB Output is correct
33 Correct 1 ms 4952 KB Output is correct
34 Correct 2 ms 4952 KB Output is correct
35 Correct 3 ms 4952 KB Output is correct
36 Correct 5 ms 5208 KB Output is correct
37 Correct 7 ms 5208 KB Output is correct
38 Correct 4 ms 5208 KB Output is correct
39 Correct 2 ms 4952 KB Output is correct
40 Correct 1 ms 5180 KB Output is correct
41 Correct 1 ms 4952 KB Output is correct
42 Correct 2 ms 4952 KB Output is correct
43 Correct 891 ms 5208 KB Output is correct
44 Correct 1277 ms 5208 KB Output is correct
45 Correct 1360 ms 5208 KB Output is correct
46 Correct 1771 ms 5464 KB Output is correct
47 Correct 1915 ms 5464 KB Output is correct
48 Correct 1839 ms 5464 KB Output is correct
49 Correct 1828 ms 5464 KB Output is correct
50 Correct 2000 ms 5464 KB Output is correct
51 Correct 2055 ms 5460 KB Output is correct
52 Correct 1910 ms 5208 KB Output is correct
53 Correct 586 ms 5464 KB Output is correct
54 Correct 1836 ms 5464 KB Output is correct
55 Correct 1847 ms 5208 KB Output is correct
56 Correct 1831 ms 5208 KB Output is correct
57 Correct 1816 ms 5208 KB Output is correct
58 Correct 1909 ms 5720 KB Output is correct
59 Correct 1889 ms 5720 KB Output is correct
60 Correct 2027 ms 5872 KB Output is correct
61 Correct 1210 ms 5472 KB Output is correct
62 Correct 1470 ms 5208 KB Output is correct
63 Correct 1473 ms 5208 KB Output is correct
64 Correct 1855 ms 5208 KB Output is correct
65 Correct 591 ms 5368 KB Output is correct
66 Correct 1669 ms 5208 KB Output is correct
67 Correct 1695 ms 5208 KB Output is correct
68 Correct 1826 ms 5464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 4 ms 4996 KB Output is correct
4 Correct 7 ms 4952 KB Output is correct
5 Correct 6 ms 5156 KB Output is correct
6 Correct 7 ms 4948 KB Output is correct
7 Correct 4 ms 4952 KB Output is correct
8 Correct 4 ms 4952 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4972 KB Output is correct
11 Correct 2 ms 4952 KB Output is correct
12 Correct 1 ms 4952 KB Output is correct
13 Correct 2 ms 4952 KB Output is correct
14 Correct 1 ms 4952 KB Output is correct
15 Correct 2 ms 5208 KB Output is correct
16 Correct 2 ms 5204 KB Output is correct
17 Correct 2 ms 5208 KB Output is correct
18 Correct 7 ms 5280 KB Output is correct
19 Correct 5 ms 5208 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 1 ms 4952 KB Output is correct
22 Correct 2 ms 4952 KB Output is correct
23 Correct 2 ms 4952 KB Output is correct
24 Correct 3 ms 5208 KB Output is correct
25 Correct 2 ms 5208 KB Output is correct
26 Correct 3 ms 5208 KB Output is correct
27 Correct 3 ms 5208 KB Output is correct
28 Correct 2 ms 5208 KB Output is correct
29 Correct 7 ms 4952 KB Output is correct
30 Correct 5 ms 4952 KB Output is correct
31 Correct 1 ms 5208 KB Output is correct
32 Correct 2 ms 5460 KB Output is correct
33 Correct 1 ms 4952 KB Output is correct
34 Correct 2 ms 4952 KB Output is correct
35 Correct 3 ms 4952 KB Output is correct
36 Correct 5 ms 5208 KB Output is correct
37 Correct 7 ms 5208 KB Output is correct
38 Correct 4 ms 5208 KB Output is correct
39 Correct 2 ms 4952 KB Output is correct
40 Correct 1 ms 5180 KB Output is correct
41 Correct 1 ms 4952 KB Output is correct
42 Correct 2 ms 4952 KB Output is correct
43 Execution timed out 3040 ms 7512 KB Time limit exceeded
44 Halted 0 ms 0 KB -