# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829752 | 2023-08-18T14:47:00 Z | beaconmc | Digital Circuit (IOI22_circuit) | C++17 | 3000 ms | 11316 KB |
#include "circuit.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; #define FOR(i, x, y) for(ll i=x; i<y; i++) #define FORNEG(i, x, y) for(ll i=x; i>y; i--) #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL) vector<ll> edges[100001]; ll possible[100001]; ll on[100001]; bool state[100001]; int initdfs(ll a){ if (edges[a].size() == 0) return possible[a] = 1; ll temp = 1; for (auto&i : edges[a]){ temp *= initdfs(i); temp %= 1000002022; } temp *= edges[a].size(); temp %= 1000002022; return possible[a] = temp; } void dfs2(ll a){ if (edges[a].size()==0){ on[a] = state[a]; return; } ll dp[edges[a].size()+1][edges[a].size()+1]; FOR(i,0,edges[a].size()+1) FOR(j,0,edges[a].size()+1) dp[i][j] = 0; dp[0][0] = 1; FOR(i,0,edges[a].size()){ dfs2(edges[a][i]); FOR(j,0,edges[a].size()){ dp[i+1][j] += dp[i][j] * (possible[edges[a][i]] - on[edges[a][i]]); dp[i+1][j+1] += dp[i][j] * on[edges[a][i]]; } } ll ans = 0; ll cur = 0; FORNEG(i,edges[a].size(),0){ ans += dp[edges[a].size()][i] * i; ans %= 1000002022; } on[a] = (ans+1000002022)%1000002022; } void init(int N, int M, std::vector<int> P, std::vector<int> A) { FOR(i,1,N+M){ edges[P[i]].push_back(i); } FOR(i,N,N+M){ state[i] = A[i-N]; } initdfs(0); } int count_ways(int L, int R) { FOR(i,0,100001) on[i] = -1; FOR(i,L,R+1){ state[i] = (state[i]+1)%2; } dfs2(0); return on[0]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3408 KB | Output is correct |
2 | Correct | 2 ms | 3408 KB | Output is correct |
3 | Correct | 10 ms | 10764 KB | Output is correct |
4 | Correct | 11 ms | 11216 KB | Output is correct |
5 | Correct | 11 ms | 11216 KB | Output is correct |
6 | Correct | 11 ms | 11216 KB | Output is correct |
7 | Correct | 11 ms | 11216 KB | Output is correct |
8 | Correct | 12 ms | 11316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 3408 KB | Output is correct |
2 | Correct | 2 ms | 3408 KB | Output is correct |
3 | Correct | 2 ms | 3408 KB | Output is correct |
4 | Correct | 2 ms | 3408 KB | Output is correct |
5 | Correct | 2 ms | 3408 KB | Output is correct |
6 | Correct | 2 ms | 3408 KB | Output is correct |
7 | Correct | 2 ms | 3408 KB | Output is correct |
8 | Correct | 2 ms | 3408 KB | Output is correct |
9 | Correct | 2 ms | 3468 KB | Output is correct |
10 | Correct | 3 ms | 3664 KB | Output is correct |
11 | Correct | 2 ms | 3664 KB | Output is correct |
12 | Correct | 2 ms | 3424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3408 KB | Output is correct |
2 | Correct | 2 ms | 3408 KB | Output is correct |
3 | Correct | 10 ms | 10764 KB | Output is correct |
4 | Correct | 11 ms | 11216 KB | Output is correct |
5 | Correct | 11 ms | 11216 KB | Output is correct |
6 | Correct | 11 ms | 11216 KB | Output is correct |
7 | Correct | 11 ms | 11216 KB | Output is correct |
8 | Correct | 12 ms | 11316 KB | Output is correct |
9 | Correct | 1 ms | 3408 KB | Output is correct |
10 | Correct | 2 ms | 3408 KB | Output is correct |
11 | Correct | 2 ms | 3408 KB | Output is correct |
12 | Correct | 2 ms | 3408 KB | Output is correct |
13 | Correct | 2 ms | 3408 KB | Output is correct |
14 | Correct | 2 ms | 3408 KB | Output is correct |
15 | Correct | 2 ms | 3408 KB | Output is correct |
16 | Correct | 2 ms | 3408 KB | Output is correct |
17 | Correct | 2 ms | 3468 KB | Output is correct |
18 | Correct | 3 ms | 3664 KB | Output is correct |
19 | Correct | 2 ms | 3664 KB | Output is correct |
20 | Correct | 2 ms | 3424 KB | Output is correct |
21 | Incorrect | 2 ms | 3408 KB | 1st lines differ - on the 1st token, expected: '759476520', found: '34059192' |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3077 ms | 5336 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3077 ms | 5336 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 3408 KB | Output is correct |
2 | Correct | 2 ms | 3408 KB | Output is correct |
3 | Correct | 2 ms | 3408 KB | Output is correct |
4 | Correct | 2 ms | 3408 KB | Output is correct |
5 | Correct | 2 ms | 3408 KB | Output is correct |
6 | Correct | 2 ms | 3408 KB | Output is correct |
7 | Correct | 2 ms | 3408 KB | Output is correct |
8 | Correct | 2 ms | 3408 KB | Output is correct |
9 | Correct | 2 ms | 3468 KB | Output is correct |
10 | Correct | 3 ms | 3664 KB | Output is correct |
11 | Correct | 2 ms | 3664 KB | Output is correct |
12 | Correct | 2 ms | 3424 KB | Output is correct |
13 | Execution timed out | 3077 ms | 5336 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3408 KB | Output is correct |
2 | Correct | 2 ms | 3408 KB | Output is correct |
3 | Correct | 10 ms | 10764 KB | Output is correct |
4 | Correct | 11 ms | 11216 KB | Output is correct |
5 | Correct | 11 ms | 11216 KB | Output is correct |
6 | Correct | 11 ms | 11216 KB | Output is correct |
7 | Correct | 11 ms | 11216 KB | Output is correct |
8 | Correct | 12 ms | 11316 KB | Output is correct |
9 | Correct | 1 ms | 3408 KB | Output is correct |
10 | Correct | 2 ms | 3408 KB | Output is correct |
11 | Correct | 2 ms | 3408 KB | Output is correct |
12 | Correct | 2 ms | 3408 KB | Output is correct |
13 | Correct | 2 ms | 3408 KB | Output is correct |
14 | Correct | 2 ms | 3408 KB | Output is correct |
15 | Correct | 2 ms | 3408 KB | Output is correct |
16 | Correct | 2 ms | 3408 KB | Output is correct |
17 | Correct | 2 ms | 3468 KB | Output is correct |
18 | Correct | 3 ms | 3664 KB | Output is correct |
19 | Correct | 2 ms | 3664 KB | Output is correct |
20 | Correct | 2 ms | 3424 KB | Output is correct |
21 | Incorrect | 2 ms | 3408 KB | 1st lines differ - on the 1st token, expected: '759476520', found: '34059192' |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3408 KB | Output is correct |
2 | Correct | 2 ms | 3408 KB | Output is correct |
3 | Correct | 10 ms | 10764 KB | Output is correct |
4 | Correct | 11 ms | 11216 KB | Output is correct |
5 | Correct | 11 ms | 11216 KB | Output is correct |
6 | Correct | 11 ms | 11216 KB | Output is correct |
7 | Correct | 11 ms | 11216 KB | Output is correct |
8 | Correct | 12 ms | 11316 KB | Output is correct |
9 | Correct | 1 ms | 3408 KB | Output is correct |
10 | Correct | 2 ms | 3408 KB | Output is correct |
11 | Correct | 2 ms | 3408 KB | Output is correct |
12 | Correct | 2 ms | 3408 KB | Output is correct |
13 | Correct | 2 ms | 3408 KB | Output is correct |
14 | Correct | 2 ms | 3408 KB | Output is correct |
15 | Correct | 2 ms | 3408 KB | Output is correct |
16 | Correct | 2 ms | 3408 KB | Output is correct |
17 | Correct | 2 ms | 3468 KB | Output is correct |
18 | Correct | 3 ms | 3664 KB | Output is correct |
19 | Correct | 2 ms | 3664 KB | Output is correct |
20 | Correct | 2 ms | 3424 KB | Output is correct |
21 | Incorrect | 2 ms | 3408 KB | 1st lines differ - on the 1st token, expected: '759476520', found: '34059192' |
22 | Halted | 0 ms | 0 KB | - |