답안 #1057994

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1057994 2024-08-14T07:52:57 Z fuad27 디지털 회로 (IOI22_circuit) C++17
46 / 100
3000 ms 6232 KB
#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;
const long long mod=1'000'002'022; // ????? 
const int N = 1e5+10;
vector<int> child[N];
long long total[N];
long long contrib[N];
 
void dfs(int at) {
	total[at] = max(1, (int)child[at].size());
	for(int to:child[at]) {
		dfs(to);
		total[at] = (total[at] * total[to])%mod;
	}
}
void dfs2(int at) {
	long long sumtot = 0;
	for(int to:child[at]) {
		sumtot+=total[to];
		sumtot%=mod;
	}
	int c = child[at].size();
	long long pref[c];
	pref[0] = 1;
	for(int i = 1;i<c;i++) {
		pref[i] = (pref[i-1] * total[child[at][i-1]])%mod;
	}
	long long suff = 1;
	for(int i = c-1;i>=0;i--) {
		contrib[child[at][i]] = (((suff*pref[i])%mod)*contrib[at])%mod;
		dfs2(child[at][i]);
		suff = (suff*total[child[at][i]])%mod;
	}
}
vector<int> A;
int nn;
void init(int n, int m, std::vector<int> p, std::vector<int> a) {
	nn=n;
	A = a;
	for(int i = 1;i<m+n;i++) {
		child[p[i]].push_back(i);
	}
	for(int i= 0;i<m+n;i++)contrib[i] = 1;
	dfs(0);
	dfs2(0);
}
 
int count_ways(int L, int R) {
	L-=nn, R-=nn;
	for(int i = L;i<=R;i++)A[i]^=1;
	long long sum = 0;
	for(int i = 0;i<(int)A.size();i++) {
		sum=(sum+(1-A[i])*contrib[nn+i])%mod;
	}
	long long ans = (total[0]-sum)%mod;
	ans+=mod;
	ans%=mod;
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3928 KB Output is correct
2 Correct 1 ms 3928 KB Output is correct
3 Correct 2 ms 4184 KB Output is correct
4 Correct 1 ms 4184 KB Output is correct
5 Correct 1 ms 4184 KB Output is correct
6 Correct 2 ms 4184 KB Output is correct
7 Correct 1 ms 4184 KB Output is correct
8 Correct 1 ms 4184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3928 KB Output is correct
2 Correct 1 ms 4184 KB Output is correct
3 Correct 1 ms 4184 KB Output is correct
4 Correct 1 ms 4184 KB Output is correct
5 Correct 1 ms 4184 KB Output is correct
6 Correct 2 ms 4184 KB Output is correct
7 Correct 2 ms 4184 KB Output is correct
8 Correct 1 ms 4016 KB Output is correct
9 Correct 1 ms 4184 KB Output is correct
10 Correct 1 ms 4184 KB Output is correct
11 Correct 2 ms 4184 KB Output is correct
12 Correct 2 ms 4184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3928 KB Output is correct
2 Correct 1 ms 3928 KB Output is correct
3 Correct 2 ms 4184 KB Output is correct
4 Correct 1 ms 4184 KB Output is correct
5 Correct 1 ms 4184 KB Output is correct
6 Correct 2 ms 4184 KB Output is correct
7 Correct 1 ms 4184 KB Output is correct
8 Correct 1 ms 4184 KB Output is correct
9 Correct 1 ms 3928 KB Output is correct
10 Correct 1 ms 4184 KB Output is correct
11 Correct 1 ms 4184 KB Output is correct
12 Correct 1 ms 4184 KB Output is correct
13 Correct 1 ms 4184 KB Output is correct
14 Correct 2 ms 4184 KB Output is correct
15 Correct 2 ms 4184 KB Output is correct
16 Correct 1 ms 4016 KB Output is correct
17 Correct 1 ms 4184 KB Output is correct
18 Correct 1 ms 4184 KB Output is correct
19 Correct 2 ms 4184 KB Output is correct
20 Correct 2 ms 4184 KB Output is correct
21 Correct 1 ms 4184 KB Output is correct
22 Correct 1 ms 4184 KB Output is correct
23 Correct 1 ms 4184 KB Output is correct
24 Correct 2 ms 4184 KB Output is correct
25 Correct 1 ms 4184 KB Output is correct
26 Correct 2 ms 4184 KB Output is correct
27 Correct 1 ms 4184 KB Output is correct
28 Correct 1 ms 4184 KB Output is correct
29 Correct 1 ms 4184 KB Output is correct
30 Correct 1 ms 4184 KB Output is correct
31 Correct 1 ms 4184 KB Output is correct
32 Correct 1 ms 4184 KB Output is correct
33 Correct 1 ms 4184 KB Output is correct
34 Correct 1 ms 3988 KB Output is correct
35 Correct 1 ms 4184 KB Output is correct
36 Correct 1 ms 4184 KB Output is correct
37 Correct 1 ms 4276 KB Output is correct
38 Correct 2 ms 4184 KB Output is correct
39 Correct 1 ms 4184 KB Output is correct
40 Correct 1 ms 4184 KB Output is correct
41 Correct 1 ms 4184 KB Output is correct
42 Correct 1 ms 4184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3016 ms 6232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3016 ms 6232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3928 KB Output is correct
2 Correct 1 ms 4184 KB Output is correct
3 Correct 1 ms 4184 KB Output is correct
4 Correct 1 ms 4184 KB Output is correct
5 Correct 1 ms 4184 KB Output is correct
6 Correct 2 ms 4184 KB Output is correct
7 Correct 2 ms 4184 KB Output is correct
8 Correct 1 ms 4016 KB Output is correct
9 Correct 1 ms 4184 KB Output is correct
10 Correct 1 ms 4184 KB Output is correct
11 Correct 2 ms 4184 KB Output is correct
12 Correct 2 ms 4184 KB Output is correct
13 Execution timed out 3016 ms 6232 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3928 KB Output is correct
2 Correct 1 ms 3928 KB Output is correct
3 Correct 2 ms 4184 KB Output is correct
4 Correct 1 ms 4184 KB Output is correct
5 Correct 1 ms 4184 KB Output is correct
6 Correct 2 ms 4184 KB Output is correct
7 Correct 1 ms 4184 KB Output is correct
8 Correct 1 ms 4184 KB Output is correct
9 Correct 1 ms 3928 KB Output is correct
10 Correct 1 ms 4184 KB Output is correct
11 Correct 1 ms 4184 KB Output is correct
12 Correct 1 ms 4184 KB Output is correct
13 Correct 1 ms 4184 KB Output is correct
14 Correct 2 ms 4184 KB Output is correct
15 Correct 2 ms 4184 KB Output is correct
16 Correct 1 ms 4016 KB Output is correct
17 Correct 1 ms 4184 KB Output is correct
18 Correct 1 ms 4184 KB Output is correct
19 Correct 2 ms 4184 KB Output is correct
20 Correct 2 ms 4184 KB Output is correct
21 Correct 1 ms 4184 KB Output is correct
22 Correct 1 ms 4184 KB Output is correct
23 Correct 1 ms 4184 KB Output is correct
24 Correct 2 ms 4184 KB Output is correct
25 Correct 1 ms 4184 KB Output is correct
26 Correct 2 ms 4184 KB Output is correct
27 Correct 1 ms 4184 KB Output is correct
28 Correct 1 ms 4184 KB Output is correct
29 Correct 1 ms 4184 KB Output is correct
30 Correct 1 ms 4184 KB Output is correct
31 Correct 1 ms 4184 KB Output is correct
32 Correct 1 ms 4184 KB Output is correct
33 Correct 1 ms 4184 KB Output is correct
34 Correct 1 ms 3988 KB Output is correct
35 Correct 1 ms 4184 KB Output is correct
36 Correct 1 ms 4184 KB Output is correct
37 Correct 1 ms 4276 KB Output is correct
38 Correct 2 ms 4184 KB Output is correct
39 Correct 1 ms 4184 KB Output is correct
40 Correct 1 ms 4184 KB Output is correct
41 Correct 1 ms 4184 KB Output is correct
42 Correct 1 ms 4184 KB Output is correct
43 Correct 1018 ms 4184 KB Output is correct
44 Correct 1373 ms 4184 KB Output is correct
45 Correct 1508 ms 4184 KB Output is correct
46 Correct 2077 ms 4440 KB Output is correct
47 Correct 2220 ms 4440 KB Output is correct
48 Correct 2174 ms 4440 KB Output is correct
49 Correct 2191 ms 4440 KB Output is correct
50 Correct 2369 ms 4440 KB Output is correct
51 Correct 2360 ms 4184 KB Output is correct
52 Correct 2139 ms 4184 KB Output is correct
53 Correct 468 ms 4696 KB Output is correct
54 Correct 2188 ms 4440 KB Output is correct
55 Correct 2211 ms 4184 KB Output is correct
56 Correct 2173 ms 4184 KB Output is correct
57 Correct 2191 ms 4184 KB Output is correct
58 Correct 2171 ms 4952 KB Output is correct
59 Correct 2183 ms 5148 KB Output is correct
60 Correct 2363 ms 5156 KB Output is correct
61 Correct 1307 ms 4440 KB Output is correct
62 Correct 1747 ms 4184 KB Output is correct
63 Correct 1759 ms 4184 KB Output is correct
64 Correct 2206 ms 4184 KB Output is correct
65 Correct 629 ms 4184 KB Output is correct
66 Correct 1945 ms 4440 KB Output is correct
67 Correct 1891 ms 4440 KB Output is correct
68 Correct 2101 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3928 KB Output is correct
2 Correct 1 ms 3928 KB Output is correct
3 Correct 2 ms 4184 KB Output is correct
4 Correct 1 ms 4184 KB Output is correct
5 Correct 1 ms 4184 KB Output is correct
6 Correct 2 ms 4184 KB Output is correct
7 Correct 1 ms 4184 KB Output is correct
8 Correct 1 ms 4184 KB Output is correct
9 Correct 1 ms 3928 KB Output is correct
10 Correct 1 ms 4184 KB Output is correct
11 Correct 1 ms 4184 KB Output is correct
12 Correct 1 ms 4184 KB Output is correct
13 Correct 1 ms 4184 KB Output is correct
14 Correct 2 ms 4184 KB Output is correct
15 Correct 2 ms 4184 KB Output is correct
16 Correct 1 ms 4016 KB Output is correct
17 Correct 1 ms 4184 KB Output is correct
18 Correct 1 ms 4184 KB Output is correct
19 Correct 2 ms 4184 KB Output is correct
20 Correct 2 ms 4184 KB Output is correct
21 Correct 1 ms 4184 KB Output is correct
22 Correct 1 ms 4184 KB Output is correct
23 Correct 1 ms 4184 KB Output is correct
24 Correct 2 ms 4184 KB Output is correct
25 Correct 1 ms 4184 KB Output is correct
26 Correct 2 ms 4184 KB Output is correct
27 Correct 1 ms 4184 KB Output is correct
28 Correct 1 ms 4184 KB Output is correct
29 Correct 1 ms 4184 KB Output is correct
30 Correct 1 ms 4184 KB Output is correct
31 Correct 1 ms 4184 KB Output is correct
32 Correct 1 ms 4184 KB Output is correct
33 Correct 1 ms 4184 KB Output is correct
34 Correct 1 ms 3988 KB Output is correct
35 Correct 1 ms 4184 KB Output is correct
36 Correct 1 ms 4184 KB Output is correct
37 Correct 1 ms 4276 KB Output is correct
38 Correct 2 ms 4184 KB Output is correct
39 Correct 1 ms 4184 KB Output is correct
40 Correct 1 ms 4184 KB Output is correct
41 Correct 1 ms 4184 KB Output is correct
42 Correct 1 ms 4184 KB Output is correct
43 Execution timed out 3016 ms 6232 KB Time limit exceeded
44 Halted 0 ms 0 KB -