# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
803198 | 2023-08-03T00:25:44 Z | yeyso | Digital Circuit (IOI22_circuit) | C++17 | 3000 ms | 7248 KB |
#include "circuit.h" #include <bits/stdc++.h> using namespace std; long long mod = 1e9+2022; #include <vector> vector<long long> dp0; vector<long long> dp1; vector<vector<long long>> adj; void dfs(long long u, long long v){ //cout << u << " "; if(adj[u].size() == 2){ long long l = adj[u][0]; long long r = adj[u][1]; dfs(l, u); dfs(r, u); dp0[u] = (dp1[l] * dp0[r] % mod + dp1[r] * dp0[l] % mod + 2 * dp0[l] * dp0[r] % mod) % mod; dp1[u] = (dp1[l] * dp0[r] % mod + dp1[r] * dp0[l] % mod + 2 * dp1[l] * dp1[r] % mod) % mod; } else { } } long long n, m; void init(int N, int M, vector<int> P, vector<int> A) { n = N; m = M; dp0.resize(N+M, 0); dp1.resize(N+M, 0); for(long long i = 0; i < A.size(); i ++){ dp0[i+N] = A[i] ^ 1; dp1[i+N] = A[i]; } //for(long long i = 0; i < dp1.size(); i ++){ //cout << dp1[i] << " "; //} cout << "\n"; vector<vector<long long>> adj0(N+M, vector<long long>()); for(long long i = 0; i < P.size(); i ++){ //adj0[i].push_back(P[i]); if(i != 0) adj0[P[i]].push_back(i); } adj = adj0; } int count_ways(int L, int R) { //return 0; for(long long i = L; i <= R; i ++){ dp0[i] = dp0[i] ^ 1; dp1[i] = dp1[i] ^ 1; } dfs(0, 0); //for(long long i = 0; i < dp1.size(); i ++) cout << dp1[i] << " "; //cout << " | "; return dp1[0]; } /* g++ -std=gnu++17 -O2 -Wall -pipe -static -o circuit stub.cpp circuit.cpp dp1[i] = dp1[u] * dp0[v] + dp0[u] * dp1[v] + 2 * dp1[u] * dp1[v] 3 4 3 -1 0 1 2 1 1 0 1 0 1 0 3 4 4 5 3 6 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 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 | 408 KB | Output is correct |
7 | Correct | 1 ms | 484 KB | Output is correct |
8 | Correct | 1 ms | 464 KB | Output is correct |
9 | Correct | 1 ms | 464 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 | 464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3015 ms | 7248 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3015 ms | 7248 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 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 | 408 KB | Output is correct |
7 | Correct | 1 ms | 484 KB | Output is correct |
8 | Correct | 1 ms | 464 KB | Output is correct |
9 | Correct | 1 ms | 464 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 | 464 KB | Output is correct |
13 | Execution timed out | 3015 ms | 7248 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |