답안 #793139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793139 2023-07-25T14:20:30 Z SlavicG 디지털 회로 (IOI22_circuit) C++17
9 / 100
3000 ms 8996 KB
#include <bits/stdc++.h>
#include "circuit.h"
using namespace std;
const int N = 2e5 + 5, mod = 1000002022;
vector<int> adj[N];
int64_t dp[N][2], color[N];
void dfs(int u) {
    if(adj[u].size() == 0) {
        if(color[u]) dp[u][0] = 0, dp[u][1] = 1;
        else dp[u][0] = 1, dp[u][1] = 0;
        return;
    }
    for(int v: adj[u]) dfs(v);
    vector<vector<int>> D((int)adj[u].size() + 1, vector<int>((int)adj[u].size() + 1));
    D[0][0] = 1;
    for(int i = 0; i < (int)adj[u].size(); ++i) {
        for(int j = 0; j <= i; ++j) {
            D[i + 1][j] += D[i][j] * dp[adj[u][i]][0] % mod;
            D[i + 1][j] %= mod;
            D[i + 1][j + 1] += D[i][j] * dp[adj[u][i]][1] % mod;
            D[i + 1][j + 1] %= mod; 
        }
    }
    dp[u][0] = dp[u][1] = 0;
    for(int i = 0; i <= (int)adj[u].size(); ++i) {
        dp[u][1] += D[(int)adj[u].size()][i] * i % mod;
        dp[u][1] %= mod;
        dp[u][0] += D[(int)adj[u].size()][i] * ((int)adj[u].size() - i) % mod;
        dp[u][0] %= mod;
    }
} 
void init(int N, int M, std::vector<int> P, std::vector<int> A) {
    for(int i = 1; i < N + M; ++i) {
        adj[P[i]].push_back(i);
    }
    for(int i = 0; i < M; ++i) color[i + N] = A[i];
    dfs(0);
}

int count_ways(int L, int R) {
    for(int i = L; i <= R; ++i) {
        color[i] ^= 1;
    }
    dfs(0);
    return dp[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 26 ms 8772 KB Output is correct
4 Correct 27 ms 8936 KB Output is correct
5 Correct 28 ms 8952 KB Output is correct
6 Correct 28 ms 8944 KB Output is correct
7 Correct 28 ms 8996 KB Output is correct
8 Correct 28 ms 8956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 3 ms 4944 KB Output is correct
4 Correct 3 ms 4944 KB Output is correct
5 Correct 3 ms 4944 KB Output is correct
6 Correct 3 ms 5072 KB Output is correct
7 Correct 3 ms 5072 KB Output is correct
8 Correct 3 ms 5072 KB Output is correct
9 Correct 3 ms 5072 KB Output is correct
10 Correct 4 ms 5200 KB Output is correct
11 Correct 3 ms 5200 KB Output is correct
12 Correct 3 ms 5072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 26 ms 8772 KB Output is correct
4 Correct 27 ms 8936 KB Output is correct
5 Correct 28 ms 8952 KB Output is correct
6 Correct 28 ms 8944 KB Output is correct
7 Correct 28 ms 8996 KB Output is correct
8 Correct 28 ms 8956 KB Output is correct
9 Correct 2 ms 4944 KB Output is correct
10 Correct 2 ms 4944 KB Output is correct
11 Correct 3 ms 4944 KB Output is correct
12 Correct 3 ms 4944 KB Output is correct
13 Correct 3 ms 4944 KB Output is correct
14 Correct 3 ms 5072 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 3 ms 5072 KB Output is correct
18 Correct 4 ms 5200 KB Output is correct
19 Correct 3 ms 5200 KB Output is correct
20 Correct 3 ms 5072 KB Output is correct
21 Incorrect 3 ms 5072 KB 1st lines differ - on the 1st token, expected: '759476520', found: '209107816'
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3057 ms 8088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3057 ms 8088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 3 ms 4944 KB Output is correct
4 Correct 3 ms 4944 KB Output is correct
5 Correct 3 ms 4944 KB Output is correct
6 Correct 3 ms 5072 KB Output is correct
7 Correct 3 ms 5072 KB Output is correct
8 Correct 3 ms 5072 KB Output is correct
9 Correct 3 ms 5072 KB Output is correct
10 Correct 4 ms 5200 KB Output is correct
11 Correct 3 ms 5200 KB Output is correct
12 Correct 3 ms 5072 KB Output is correct
13 Execution timed out 3057 ms 8088 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 26 ms 8772 KB Output is correct
4 Correct 27 ms 8936 KB Output is correct
5 Correct 28 ms 8952 KB Output is correct
6 Correct 28 ms 8944 KB Output is correct
7 Correct 28 ms 8996 KB Output is correct
8 Correct 28 ms 8956 KB Output is correct
9 Correct 2 ms 4944 KB Output is correct
10 Correct 2 ms 4944 KB Output is correct
11 Correct 3 ms 4944 KB Output is correct
12 Correct 3 ms 4944 KB Output is correct
13 Correct 3 ms 4944 KB Output is correct
14 Correct 3 ms 5072 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 3 ms 5072 KB Output is correct
18 Correct 4 ms 5200 KB Output is correct
19 Correct 3 ms 5200 KB Output is correct
20 Correct 3 ms 5072 KB Output is correct
21 Incorrect 3 ms 5072 KB 1st lines differ - on the 1st token, expected: '759476520', found: '209107816'
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 26 ms 8772 KB Output is correct
4 Correct 27 ms 8936 KB Output is correct
5 Correct 28 ms 8952 KB Output is correct
6 Correct 28 ms 8944 KB Output is correct
7 Correct 28 ms 8996 KB Output is correct
8 Correct 28 ms 8956 KB Output is correct
9 Correct 2 ms 4944 KB Output is correct
10 Correct 2 ms 4944 KB Output is correct
11 Correct 3 ms 4944 KB Output is correct
12 Correct 3 ms 4944 KB Output is correct
13 Correct 3 ms 4944 KB Output is correct
14 Correct 3 ms 5072 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 3 ms 5072 KB Output is correct
18 Correct 4 ms 5200 KB Output is correct
19 Correct 3 ms 5200 KB Output is correct
20 Correct 3 ms 5072 KB Output is correct
21 Incorrect 3 ms 5072 KB 1st lines differ - on the 1st token, expected: '759476520', found: '209107816'
22 Halted 0 ms 0 KB -