# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
790457 | 2023-07-22T16:55:48 Z | borisAngelov | Digital Circuit (IOI22_circuit) | C++17 | 8 ms | 2256 KB |
#include "circuit.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1005; const long long mod = 1e9 + 2022; int n, m; long long dp[maxn][2]; int color[maxn]; vector<int> tree[2 * maxn]; void dfs(int node) { dp[node][0] = 0; dp[node][1] = 0; if (tree[node].empty()) { dp[node][1] = color[node]; dp[node][0] = 1 - dp[node][1]; return; } int l = tree[node][0]; int r = tree[node][1]; dfs(l); dfs(r); dp[node][0] = dp[l][0] * dp[r][1] + dp[l][1] * dp[r][0] + 2 * dp[l][0] * dp[r][0]; dp[node][0] %= mod; dp[node][1] = dp[l][0] * dp[r][1] + dp[l][1] * dp[r][0] + 2 * dp[l][1] * dp[r][1]; 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[n - i - 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '1', found: '-32' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '1', found: '-32' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '1', found: '-32' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 8 ms | 2256 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 8 ms | 2256 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '1', found: '-32' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '1', found: '-32' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '1', found: '-32' |
2 | Halted | 0 ms | 0 KB | - |