답안 #736316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
736316 2023-05-05T12:35:40 Z jk410 디지털 회로 (IOI22_circuit) C++17
2 / 100
3000 ms 32464 KB
#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000002022;

int n, m;
vector<int> p, a;
vector<int> child[2023];
ll dp[1023], dp2[2023][2023];
ll dpAll[1023];

ll getDPAll(int v) {
	ll& ret = dpAll[v] = (int)child[v].size();
	for (int i : child[v]) {
		if (i < n)
			ret = ret * getDPAll(i) % MOD;
	}
	return ret;
}

void init(int _n, int _m, vector<int> _p, vector<int> _a) {
	n = _n;
	m = _m;
	p = _p;
	a = _a;
	for (int i = 1; i < n + m; i++)
		child[p[i]].push_back(i);
	getDPAll(0);
}

void getDP(int v) {
	int sz = (int)child[v].size();
	for (int i : child[v]) {
		if (i < n)
			getDP(i);
	}
	memset(dp2, 0, sizeof(dp2));
	dp2[0][0] = 1;
	ll tmp = 1;
	for (int i = 1; i <= sz; i++) {
		int cur = child[v][i - 1];
		ll tmp2 = 0;
		for (int j = 1; j <= i; j++) {
			if (cur < n) {
				tmp = tmp * dpAll[cur] % MOD;
				dp2[i][j] = (dp2[i - 1][j - 1] * dp[cur] % MOD + dp2[i - 1][j] * ((dpAll[cur] - dp[cur] + MOD) % MOD) % MOD) % MOD;
			}
			else {
				if (a[cur - n])
					dp2[i][j] = dp2[i - 1][j - 1];
				else
					dp2[i][j] = dp2[i - 1][j];
			}
			tmp2 = (tmp2 + dp2[i][j]) % MOD;
		}
		dp2[i][0] = (tmp - tmp2 + MOD) % MOD;
	}
	dp[v] = 0;
	for (int i = 1; i <= sz; i++)
		dp[v] = (dp[v] + dp2[sz][i] * i % MOD) % MOD;
}

int count_ways(int l, int r) {
	for (int i = l - n; i <= r - n; i++)
		a[i] ^= 1;
	getDP(0);
	return dp[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 32336 KB Output is correct
2 Correct 22 ms 32332 KB Output is correct
3 Correct 34 ms 32336 KB Output is correct
4 Correct 34 ms 32336 KB Output is correct
5 Correct 34 ms 32336 KB Output is correct
6 Correct 34 ms 32336 KB Output is correct
7 Correct 37 ms 32316 KB Output is correct
8 Correct 36 ms 32388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 32336 KB Output is correct
2 Correct 2433 ms 32464 KB Output is correct
3 Execution timed out 3067 ms 32404 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 32336 KB Output is correct
2 Correct 22 ms 32332 KB Output is correct
3 Correct 34 ms 32336 KB Output is correct
4 Correct 34 ms 32336 KB Output is correct
5 Correct 34 ms 32336 KB Output is correct
6 Correct 34 ms 32336 KB Output is correct
7 Correct 37 ms 32316 KB Output is correct
8 Correct 36 ms 32388 KB Output is correct
9 Correct 25 ms 32336 KB Output is correct
10 Correct 2433 ms 32464 KB Output is correct
11 Execution timed out 3067 ms 32404 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 3056 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 3056 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 32336 KB Output is correct
2 Correct 2433 ms 32464 KB Output is correct
3 Execution timed out 3067 ms 32404 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 32336 KB Output is correct
2 Correct 22 ms 32332 KB Output is correct
3 Correct 34 ms 32336 KB Output is correct
4 Correct 34 ms 32336 KB Output is correct
5 Correct 34 ms 32336 KB Output is correct
6 Correct 34 ms 32336 KB Output is correct
7 Correct 37 ms 32316 KB Output is correct
8 Correct 36 ms 32388 KB Output is correct
9 Correct 25 ms 32336 KB Output is correct
10 Correct 2433 ms 32464 KB Output is correct
11 Execution timed out 3067 ms 32404 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 32336 KB Output is correct
2 Correct 22 ms 32332 KB Output is correct
3 Correct 34 ms 32336 KB Output is correct
4 Correct 34 ms 32336 KB Output is correct
5 Correct 34 ms 32336 KB Output is correct
6 Correct 34 ms 32336 KB Output is correct
7 Correct 37 ms 32316 KB Output is correct
8 Correct 36 ms 32388 KB Output is correct
9 Correct 25 ms 32336 KB Output is correct
10 Correct 2433 ms 32464 KB Output is correct
11 Execution timed out 3067 ms 32404 KB Time limit exceeded
12 Halted 0 ms 0 KB -