답안 #1024432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1024432 2024-07-16T05:07:25 Z vjudge1 디지털 회로 (IOI22_circuit) C++17
18 / 100
3000 ms 6488 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<int, int> pii;

const int MOD = 1000002022;
const int maxn = 1e5 + 100;

int n, k;
int p[maxn];
vector<int> g[maxn];
int a[maxn];
ll dp[2][maxn];

void init(int N, int M, std::vector<int> P, std::vector<int> A){
	int n = N + M; k = N;
	for(int i = 1; i <= n; i++){
		p[i] = P[i-1]; p[i]++;
		g[p[i]].push_back(i);
	}
	for(int i = k + 1; i <= n; i++){
		a[i] = A[i - k - 1];
		dp[a[i]][i] = 1;
		dp[a[i]^1][i] = 0;
	}
}

int count_ways(int L, int R){
	for(int i = L + 1; i <= R + 1; i++){
		a[i] ^= 1;
		dp[a[i]][i] = 1;
		dp[a[i]^1][i] = 0;
	}
	for(int v = k; v > 0; v--){
		vector<ll> d(g[v].size() + 1, 0);
		d[0] = 1; dp[1][v] = dp[0][v] = 0;
		for(int to: g[v]){
			for(int cnt = g[v].size(); cnt >= 0; cnt--){
				d[cnt] = d[cnt] * dp[0][to] % MOD;
				if(cnt) d[cnt] = (d[cnt] + d[cnt-1] * dp[1][to]) % MOD;
			}
		}
		for(int cnt = 0; cnt <= g[v].size(); cnt++){
			dp[1][v] = (dp[1][v] + d[cnt] * cnt) % MOD;
			dp[0][v] = (dp[0][v] + d[cnt] * (g[v].size() - cnt)) % MOD;
		}
	}
	return dp[1][1];
}

Compilation message

circuit.cpp: In function 'int count_ways(int, int)':
circuit.cpp:43:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int cnt = 0; cnt <= g[v].size(); cnt++){
      |                    ~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 14 ms 4440 KB Output is correct
4 Correct 12 ms 4440 KB Output is correct
5 Correct 12 ms 4440 KB Output is correct
6 Correct 12 ms 4440 KB Output is correct
7 Correct 12 ms 4440 KB Output is correct
8 Correct 12 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4568 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 2 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 14 ms 4440 KB Output is correct
4 Correct 12 ms 4440 KB Output is correct
5 Correct 12 ms 4440 KB Output is correct
6 Correct 12 ms 4440 KB Output is correct
7 Correct 12 ms 4440 KB Output is correct
8 Correct 12 ms 4440 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4568 KB Output is correct
12 Correct 1 ms 4440 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 2 ms 4440 KB Output is correct
19 Correct 1 ms 4440 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4440 KB Output is correct
22 Correct 2 ms 4440 KB Output is correct
23 Correct 1 ms 4440 KB Output is correct
24 Correct 1 ms 4440 KB Output is correct
25 Correct 1 ms 4440 KB Output is correct
26 Correct 1 ms 4440 KB Output is correct
27 Correct 1 ms 4440 KB Output is correct
28 Correct 1 ms 4440 KB Output is correct
29 Correct 13 ms 4440 KB Output is correct
30 Correct 12 ms 4440 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 1 ms 4440 KB Output is correct
33 Correct 1 ms 4440 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 3 ms 4440 KB Output is correct
36 Correct 1 ms 4440 KB Output is correct
37 Correct 12 ms 4660 KB Output is correct
38 Correct 12 ms 4668 KB Output is correct
39 Correct 1 ms 4440 KB Output is correct
40 Correct 1 ms 4440 KB Output is correct
41 Correct 1 ms 4440 KB Output is correct
42 Correct 1 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3042 ms 6488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3042 ms 6488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4568 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 2 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4440 KB Output is correct
13 Execution timed out 3042 ms 6488 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 14 ms 4440 KB Output is correct
4 Correct 12 ms 4440 KB Output is correct
5 Correct 12 ms 4440 KB Output is correct
6 Correct 12 ms 4440 KB Output is correct
7 Correct 12 ms 4440 KB Output is correct
8 Correct 12 ms 4440 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4568 KB Output is correct
12 Correct 1 ms 4440 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 2 ms 4440 KB Output is correct
19 Correct 1 ms 4440 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4440 KB Output is correct
22 Correct 2 ms 4440 KB Output is correct
23 Correct 1 ms 4440 KB Output is correct
24 Correct 1 ms 4440 KB Output is correct
25 Correct 1 ms 4440 KB Output is correct
26 Correct 1 ms 4440 KB Output is correct
27 Correct 1 ms 4440 KB Output is correct
28 Correct 1 ms 4440 KB Output is correct
29 Correct 13 ms 4440 KB Output is correct
30 Correct 12 ms 4440 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 1 ms 4440 KB Output is correct
33 Correct 1 ms 4440 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 3 ms 4440 KB Output is correct
36 Correct 1 ms 4440 KB Output is correct
37 Correct 12 ms 4660 KB Output is correct
38 Correct 12 ms 4668 KB Output is correct
39 Correct 1 ms 4440 KB Output is correct
40 Correct 1 ms 4440 KB Output is correct
41 Correct 1 ms 4440 KB Output is correct
42 Correct 1 ms 4440 KB Output is correct
43 Execution timed out 3062 ms 4696 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 14 ms 4440 KB Output is correct
4 Correct 12 ms 4440 KB Output is correct
5 Correct 12 ms 4440 KB Output is correct
6 Correct 12 ms 4440 KB Output is correct
7 Correct 12 ms 4440 KB Output is correct
8 Correct 12 ms 4440 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4568 KB Output is correct
12 Correct 1 ms 4440 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 2 ms 4440 KB Output is correct
19 Correct 1 ms 4440 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4440 KB Output is correct
22 Correct 2 ms 4440 KB Output is correct
23 Correct 1 ms 4440 KB Output is correct
24 Correct 1 ms 4440 KB Output is correct
25 Correct 1 ms 4440 KB Output is correct
26 Correct 1 ms 4440 KB Output is correct
27 Correct 1 ms 4440 KB Output is correct
28 Correct 1 ms 4440 KB Output is correct
29 Correct 13 ms 4440 KB Output is correct
30 Correct 12 ms 4440 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 1 ms 4440 KB Output is correct
33 Correct 1 ms 4440 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 3 ms 4440 KB Output is correct
36 Correct 1 ms 4440 KB Output is correct
37 Correct 12 ms 4660 KB Output is correct
38 Correct 12 ms 4668 KB Output is correct
39 Correct 1 ms 4440 KB Output is correct
40 Correct 1 ms 4440 KB Output is correct
41 Correct 1 ms 4440 KB Output is correct
42 Correct 1 ms 4440 KB Output is correct
43 Execution timed out 3042 ms 6488 KB Time limit exceeded
44 Halted 0 ms 0 KB -