# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
652754 | 2022-10-24T08:21:24 Z | Blagoj | Digital Circuit (IOI22_circuit) | C++17 | 10 ms | 2384 KB |
#include "circuit.h" #include <bits/stdc++.h> using namespace std; vector<int> states; vector<int> kids[1009]; int n, m; long long mod = 1000002022; void init(int N, int M, std::vector<int> P, std::vector<int> A) { states = A; n = N; m = M; for (int i = 1; i < P.size(); i++) { kids[P[i]].push_back(i); } } long long dp[3000][2]; bool solved[3000]; int solve(int x) { solved[x] = true; int k1 = kids[x][0], k2 = kids[x][1]; if (dp[k1][0] == -1 || dp[k1][1] == -1) { solve(k1); } if (dp[k2][0] == -1 || dp[k2][1] == -1) { solve(k2); } dp[x][0] = dp[k1][0] * dp[k2][1] + dp[k1][1] * dp[k2][0] + 2 * dp[k1][0] * dp[k2][0]; dp[x][1] = dp[k1][0] * dp[k2][1] + dp[k1][1] * dp[k2][0] + 2 * dp[k1][1] * dp[k2][1]; } int count_ways(int L, int R) { for (int i = L - n; i <= R - n; i++) { if (states[i] == 0) { states[i] = 1; } else { states[i] = 0; } } if (n == 1) { int ans = 0; for (int i = 1; i <= m; i++) { ans += states[i]; } return ans; } for (int i = 0; i < n; i++) { dp[i][0] = dp[i][1] = -1; } for (int i = n; i < n + m; i++) { if (states[i] == 1) { dp[i][1] = 1; dp[i][0] = 0; } else { dp[i][1] = 0; dp[i][0] = 1; } } memset(solved, 0, sizeof(solved)); for (int i = 0; i < n; i++) { if (!solved[i]) { solve(i); } } return dp[0][1]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | 1st lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 10 ms | 2384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 10 ms | 2384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 208 KB | 1st lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |