# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
638244 | 2022-09-05T05:58:54 Z | jamezzz | 디지털 회로 (IOI22_circuit) | C++17 | 3000 ms | 13136 KB |
#include "circuit.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define maxn 100005 #define mod 1000002022 int N,M,ways[maxn][2],pfx[maxn]; vector<int> A,AL[maxn]; vector<vector<ll>> memo[maxn]; void init(int _N,int _M,vector<int> P,vector<int> _A){ N=_N,M=_M; for(int i=0;i<N;++i)A.push_back(0); for(int i=N;i<N+M;++i){ A.push_back(_A[i-N]); ways[i][0]=(A[i]==0); ways[i][1]=(A[i]==1); } for(int i=1;i<N+M;++i){ AL[P[i]].push_back(i); } for(int i=0;i<N;++i){ memo[i].resize(AL[i].size()); for(int j=0;j<AL[i].size();++j){ memo[i][j].resize(AL[i].size()+1); } } } int dp(int u){ int n=AL[u].size(); for(int i=0;i<n;++i){ int v=AL[u][i]; if(v<N)dp(v); if(i==0){ for(int j=0;j<=n;++j){ memo[u][i][j]=0; } memo[u][i][0]=ways[v][0]; memo[u][i][1]=ways[v][1]; } else{ for(int j=0;j<=n;++j){ memo[u][i][j]=(memo[u][i-1][j]*ways[v][0])%mod; if(j!=0){ memo[u][i][j]+=(memo[u][i-1][j-1]*ways[v][1])%mod; memo[u][i][j]%=mod; } } } } ways[u][0]=ways[u][1]=0; for(int i=0;i<=n;++i){ if(i==0)pfx[i]=(int)memo[u][n-1][i]; else pfx[i]=pfx[i-1]+(int)memo[u][n-1][i]; pfx[i]%=mod; } for(int i=1;i<=n;++i){//if p=i ways[u][0]+=pfx[i-1]; ways[u][1]+=(pfx[n]-pfx[i-1]+mod)%mod; ways[u][0]%=mod; ways[u][1]%=mod; } return ways[u][1]; } int count_ways(int L,int R){ for(int i=L;i<=R;++i){ A[i]=1-A[i]; swap(ways[i][0],ways[i][1]); } return dp(0); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4944 KB | Output is correct |
2 | Correct | 3 ms | 4944 KB | Output is correct |
3 | Correct | 29 ms | 12460 KB | Output is correct |
4 | Correct | 28 ms | 12880 KB | Output is correct |
5 | Correct | 28 ms | 12880 KB | Output is correct |
6 | Correct | 27 ms | 12880 KB | Output is correct |
7 | Correct | 27 ms | 12904 KB | Output is correct |
8 | Correct | 28 ms | 12892 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4944 KB | Output is correct |
2 | Correct | 4 ms | 4944 KB | Output is correct |
3 | Correct | 3 ms | 5072 KB | Output is correct |
4 | Correct | 3 ms | 5072 KB | Output is correct |
5 | Correct | 3 ms | 5072 KB | Output is correct |
6 | Correct | 3 ms | 5072 KB | Output is correct |
7 | Correct | 4 ms | 5200 KB | Output is correct |
8 | Correct | 4 ms | 5200 KB | Output is correct |
9 | Correct | 4 ms | 5200 KB | Output is correct |
10 | Correct | 3 ms | 5328 KB | Output is correct |
11 | Correct | 3 ms | 5200 KB | Output is correct |
12 | Correct | 5 ms | 5072 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4944 KB | Output is correct |
2 | Correct | 3 ms | 4944 KB | Output is correct |
3 | Correct | 29 ms | 12460 KB | Output is correct |
4 | Correct | 28 ms | 12880 KB | Output is correct |
5 | Correct | 28 ms | 12880 KB | Output is correct |
6 | Correct | 27 ms | 12880 KB | Output is correct |
7 | Correct | 27 ms | 12904 KB | Output is correct |
8 | Correct | 28 ms | 12892 KB | Output is correct |
9 | Correct | 3 ms | 4944 KB | Output is correct |
10 | Correct | 4 ms | 4944 KB | Output is correct |
11 | Correct | 3 ms | 5072 KB | Output is correct |
12 | Correct | 3 ms | 5072 KB | Output is correct |
13 | Correct | 3 ms | 5072 KB | Output is correct |
14 | Correct | 3 ms | 5072 KB | Output is correct |
15 | Correct | 4 ms | 5200 KB | Output is correct |
16 | Correct | 4 ms | 5200 KB | Output is correct |
17 | Correct | 4 ms | 5200 KB | Output is correct |
18 | Correct | 3 ms | 5328 KB | Output is correct |
19 | Correct | 3 ms | 5200 KB | Output is correct |
20 | Correct | 5 ms | 5072 KB | Output is correct |
21 | Correct | 3 ms | 5072 KB | Output is correct |
22 | Correct | 3 ms | 5072 KB | Output is correct |
23 | Correct | 3 ms | 5072 KB | Output is correct |
24 | Correct | 4 ms | 5200 KB | Output is correct |
25 | Correct | 4 ms | 5200 KB | Output is correct |
26 | Correct | 4 ms | 5200 KB | Output is correct |
27 | Correct | 4 ms | 5200 KB | Output is correct |
28 | Correct | 4 ms | 5200 KB | Output is correct |
29 | Correct | 28 ms | 12904 KB | Output is correct |
30 | Correct | 28 ms | 12880 KB | Output is correct |
31 | Correct | 3 ms | 5240 KB | Output is correct |
32 | Correct | 4 ms | 5200 KB | Output is correct |
33 | Correct | 3 ms | 5072 KB | Output is correct |
34 | Correct | 3 ms | 5072 KB | Output is correct |
35 | Correct | 8 ms | 6608 KB | Output is correct |
36 | Correct | 3 ms | 5200 KB | Output is correct |
37 | Correct | 29 ms | 13136 KB | Output is correct |
38 | Correct | 27 ms | 13136 KB | Output is correct |
39 | Correct | 3 ms | 5072 KB | Output is correct |
40 | Correct | 3 ms | 5072 KB | Output is correct |
41 | Correct | 4 ms | 5072 KB | Output is correct |
42 | Correct | 4 ms | 5200 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3011 ms | 11404 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3011 ms | 11404 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4944 KB | Output is correct |
2 | Correct | 4 ms | 4944 KB | Output is correct |
3 | Correct | 3 ms | 5072 KB | Output is correct |
4 | Correct | 3 ms | 5072 KB | Output is correct |
5 | Correct | 3 ms | 5072 KB | Output is correct |
6 | Correct | 3 ms | 5072 KB | Output is correct |
7 | Correct | 4 ms | 5200 KB | Output is correct |
8 | Correct | 4 ms | 5200 KB | Output is correct |
9 | Correct | 4 ms | 5200 KB | Output is correct |
10 | Correct | 3 ms | 5328 KB | Output is correct |
11 | Correct | 3 ms | 5200 KB | Output is correct |
12 | Correct | 5 ms | 5072 KB | Output is correct |
13 | Execution timed out | 3011 ms | 11404 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4944 KB | Output is correct |
2 | Correct | 3 ms | 4944 KB | Output is correct |
3 | Correct | 29 ms | 12460 KB | Output is correct |
4 | Correct | 28 ms | 12880 KB | Output is correct |
5 | Correct | 28 ms | 12880 KB | Output is correct |
6 | Correct | 27 ms | 12880 KB | Output is correct |
7 | Correct | 27 ms | 12904 KB | Output is correct |
8 | Correct | 28 ms | 12892 KB | Output is correct |
9 | Correct | 3 ms | 4944 KB | Output is correct |
10 | Correct | 4 ms | 4944 KB | Output is correct |
11 | Correct | 3 ms | 5072 KB | Output is correct |
12 | Correct | 3 ms | 5072 KB | Output is correct |
13 | Correct | 3 ms | 5072 KB | Output is correct |
14 | Correct | 3 ms | 5072 KB | Output is correct |
15 | Correct | 4 ms | 5200 KB | Output is correct |
16 | Correct | 4 ms | 5200 KB | Output is correct |
17 | Correct | 4 ms | 5200 KB | Output is correct |
18 | Correct | 3 ms | 5328 KB | Output is correct |
19 | Correct | 3 ms | 5200 KB | Output is correct |
20 | Correct | 5 ms | 5072 KB | Output is correct |
21 | Correct | 3 ms | 5072 KB | Output is correct |
22 | Correct | 3 ms | 5072 KB | Output is correct |
23 | Correct | 3 ms | 5072 KB | Output is correct |
24 | Correct | 4 ms | 5200 KB | Output is correct |
25 | Correct | 4 ms | 5200 KB | Output is correct |
26 | Correct | 4 ms | 5200 KB | Output is correct |
27 | Correct | 4 ms | 5200 KB | Output is correct |
28 | Correct | 4 ms | 5200 KB | Output is correct |
29 | Correct | 28 ms | 12904 KB | Output is correct |
30 | Correct | 28 ms | 12880 KB | Output is correct |
31 | Correct | 3 ms | 5240 KB | Output is correct |
32 | Correct | 4 ms | 5200 KB | Output is correct |
33 | Correct | 3 ms | 5072 KB | Output is correct |
34 | Correct | 3 ms | 5072 KB | Output is correct |
35 | Correct | 8 ms | 6608 KB | Output is correct |
36 | Correct | 3 ms | 5200 KB | Output is correct |
37 | Correct | 29 ms | 13136 KB | Output is correct |
38 | Correct | 27 ms | 13136 KB | Output is correct |
39 | Correct | 3 ms | 5072 KB | Output is correct |
40 | Correct | 3 ms | 5072 KB | Output is correct |
41 | Correct | 4 ms | 5072 KB | Output is correct |
42 | Correct | 4 ms | 5200 KB | Output is correct |
43 | Execution timed out | 3068 ms | 5584 KB | Time limit exceeded |
44 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4944 KB | Output is correct |
2 | Correct | 3 ms | 4944 KB | Output is correct |
3 | Correct | 29 ms | 12460 KB | Output is correct |
4 | Correct | 28 ms | 12880 KB | Output is correct |
5 | Correct | 28 ms | 12880 KB | Output is correct |
6 | Correct | 27 ms | 12880 KB | Output is correct |
7 | Correct | 27 ms | 12904 KB | Output is correct |
8 | Correct | 28 ms | 12892 KB | Output is correct |
9 | Correct | 3 ms | 4944 KB | Output is correct |
10 | Correct | 4 ms | 4944 KB | Output is correct |
11 | Correct | 3 ms | 5072 KB | Output is correct |
12 | Correct | 3 ms | 5072 KB | Output is correct |
13 | Correct | 3 ms | 5072 KB | Output is correct |
14 | Correct | 3 ms | 5072 KB | Output is correct |
15 | Correct | 4 ms | 5200 KB | Output is correct |
16 | Correct | 4 ms | 5200 KB | Output is correct |
17 | Correct | 4 ms | 5200 KB | Output is correct |
18 | Correct | 3 ms | 5328 KB | Output is correct |
19 | Correct | 3 ms | 5200 KB | Output is correct |
20 | Correct | 5 ms | 5072 KB | Output is correct |
21 | Correct | 3 ms | 5072 KB | Output is correct |
22 | Correct | 3 ms | 5072 KB | Output is correct |
23 | Correct | 3 ms | 5072 KB | Output is correct |
24 | Correct | 4 ms | 5200 KB | Output is correct |
25 | Correct | 4 ms | 5200 KB | Output is correct |
26 | Correct | 4 ms | 5200 KB | Output is correct |
27 | Correct | 4 ms | 5200 KB | Output is correct |
28 | Correct | 4 ms | 5200 KB | Output is correct |
29 | Correct | 28 ms | 12904 KB | Output is correct |
30 | Correct | 28 ms | 12880 KB | Output is correct |
31 | Correct | 3 ms | 5240 KB | Output is correct |
32 | Correct | 4 ms | 5200 KB | Output is correct |
33 | Correct | 3 ms | 5072 KB | Output is correct |
34 | Correct | 3 ms | 5072 KB | Output is correct |
35 | Correct | 8 ms | 6608 KB | Output is correct |
36 | Correct | 3 ms | 5200 KB | Output is correct |
37 | Correct | 29 ms | 13136 KB | Output is correct |
38 | Correct | 27 ms | 13136 KB | Output is correct |
39 | Correct | 3 ms | 5072 KB | Output is correct |
40 | Correct | 3 ms | 5072 KB | Output is correct |
41 | Correct | 4 ms | 5072 KB | Output is correct |
42 | Correct | 4 ms | 5200 KB | Output is correct |
43 | Execution timed out | 3011 ms | 11404 KB | Time limit exceeded |
44 | Halted | 0 ms | 0 KB | - |