# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
652758 | 2022-10-24T08:29:20 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]; void solve(int x) { if (solved[x]) { return; } 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]) % mod; dp[x][1] = (dp[k1][0] * dp[k2][1] + dp[k1][1] * dp[k2][0] + 2 * dp[k1][1] * dp[k2][1]) % mod; } 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 = 0; 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 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '52130940', found: '422283126' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 | 208 KB | Output is correct |
10 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '52130940', found: '422283126' |
11 | 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 | Correct | 1 ms | 208 KB | Output is correct |
2 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '52130940', found: '422283126' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 | 208 KB | Output is correct |
10 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '52130940', found: '422283126' |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 | 208 KB | Output is correct |
10 | Incorrect | 1 ms | 336 KB | 1st lines differ - on the 1st token, expected: '52130940', found: '422283126' |
11 | Halted | 0 ms | 0 KB | - |