답안 #1057957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1057957 2024-08-14T07:37:37 Z Huseyn123 디지털 회로 (IOI22_circuit) C++17
18 / 100
3000 ms 4436 KB
#include <bits/stdc++.h> 
#include "circuit.h"
using namespace std; 
int n,m; 
const int mod=1000002022;
vector<int> a;
vector<vector<int>> g;
long long dp[100001][2];
void dfs(int v){
  if(v>=n){
    return; 
  }
  dp[v][0]=dp[v][1]=0;
  int sz=(int)g[v].size();
  long long b[sz+1],c[sz+1];
  for(int i=0;i<=sz;i++){
    b[i]=c[i]=0;
  }
  b[0]=1;
  for(auto x:g[v]){
    dfs(x); 
    for(int i=0;i<sz;i++){
      c[i+1]+=(dp[x][1]*b[i])%mod;
      c[i]+=(dp[x][0]*b[i])%mod;
      c[i+1]%=mod; 
      c[i]%=mod;
      b[i]=c[i];
      c[i]=0;
    }
    b[sz]=c[sz];
    c[sz]=0;
  }
  long long sum=b[0];
  for(int i=1;i<=sz;i++){
    dp[v][0]+=sum; 
    dp[v][0]%=mod;
    sum+=b[i];
    sum%=mod; 
  }
  sum=0;
  for(int i=sz;i>=1;i--){
    sum+=b[i];
    sum%=mod;
    dp[v][1]+=sum; 
    dp[v][1]%=mod;
  }
}
void init(int N, int M, vector<int> P, vector<int> A) {
  n=N; 
  m=M; 
  a=A;
  g.resize(n+m);
  for(int i=1;i<n+m;i++){
    g[P[i]].push_back(i);
  }
  for(int i=0;i<m;i++){
    dp[n+i][a[i]]=1; 
    dp[n+i][1-a[i]]=0;
  }
}
int count_ways(int L, int R) {
  for(int i=L;i<=R;i++){
    a[i-n]=1-a[i-n]; 
    dp[i][a[i-n]]=1;
    dp[i][1-a[i-n]]=0;
  }
  dfs(0);
  int res=dp[0][1];
  return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 16 ms 344 KB Output is correct
4 Correct 18 ms 344 KB Output is correct
5 Correct 17 ms 344 KB Output is correct
6 Correct 20 ms 344 KB Output is correct
7 Correct 30 ms 344 KB Output is correct
8 Correct 20 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 576 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 16 ms 344 KB Output is correct
4 Correct 18 ms 344 KB Output is correct
5 Correct 17 ms 344 KB Output is correct
6 Correct 20 ms 344 KB Output is correct
7 Correct 30 ms 344 KB Output is correct
8 Correct 20 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 576 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 26 ms 344 KB Output is correct
30 Correct 19 ms 344 KB Output is correct
31 Correct 0 ms 600 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 26 ms 600 KB Output is correct
38 Correct 20 ms 600 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3047 ms 4436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3047 ms 4436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 576 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Execution timed out 3047 ms 4436 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 16 ms 344 KB Output is correct
4 Correct 18 ms 344 KB Output is correct
5 Correct 17 ms 344 KB Output is correct
6 Correct 20 ms 344 KB Output is correct
7 Correct 30 ms 344 KB Output is correct
8 Correct 20 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 576 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 26 ms 344 KB Output is correct
30 Correct 19 ms 344 KB Output is correct
31 Correct 0 ms 600 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 26 ms 600 KB Output is correct
38 Correct 20 ms 600 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Execution timed out 3065 ms 600 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 16 ms 344 KB Output is correct
4 Correct 18 ms 344 KB Output is correct
5 Correct 17 ms 344 KB Output is correct
6 Correct 20 ms 344 KB Output is correct
7 Correct 30 ms 344 KB Output is correct
8 Correct 20 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 576 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 26 ms 344 KB Output is correct
30 Correct 19 ms 344 KB Output is correct
31 Correct 0 ms 600 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 26 ms 600 KB Output is correct
38 Correct 20 ms 600 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Execution timed out 3047 ms 4436 KB Time limit exceeded
44 Halted 0 ms 0 KB -