# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
790473 | 2023-07-22T17:08:52 Z | borisAngelov | 디지털 회로 (IOI22_circuit) | C++17 | 13 ms | 2384 KB |
#include "circuit.h" #include <bits/stdc++.h> using namespace std; const int maxn = 2005; const long long mod = 1e9 + 2022; int n, m; long long dp[maxn][2]; int color[maxn]; vector<int> tree[maxn]; void dfs(int node) { dp[node][0] = 0; dp[node][1] = 0; if (tree[node].empty()) { dp[node][color[node]] = 1; dp[node][1 - color[node]] = 0; return; } int l = tree[node][0]; int r = tree[node][1]; dfs(l); dfs(r); dp[node][0] = (dp[l][0] * dp[r][1]) % mod + (dp[l][1] * dp[r][0]) % mod + (2LL * dp[l][0] * dp[r][0]) % mod; dp[node][0] %= mod; dp[node][1] = (dp[l][0] * dp[r][1]) % mod + (dp[l][1] * dp[r][0]) % mod + (2LL * dp[l][1] * dp[r][1]) % mod; dp[node][1] %= mod; } void init(int N, int M, vector<int> P, vector<int> A) { n = N; m = M; for (int i = 1; i < P.size(); ++i) { tree[P[i] + 1].push_back(i + 1); } for (int i = n + 1; i <= n + m; ++i) { color[i] = A[i - n - 1]; } } int count_ways(int L, int R) { int l = ++L; int r = ++R; for (int i = l; i <= r; ++i) { color[i] = 1 - color[i]; } dfs(1); return dp[1][1]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '509', found: '1' |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 464 KB | Output is correct |
11 | Correct | 1 ms | 464 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '509', found: '1' |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 2384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 2384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 464 KB | Output is correct |
11 | Correct | 1 ms | 464 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Runtime error | 13 ms | 2384 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '509', found: '1' |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '509', found: '1' |
4 | Halted | 0 ms | 0 KB | - |