답안 #836320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
836320 2023-08-24T10:09:53 Z ma_moutahid 디지털 회로 (IOI22_circuit) C++17
18 / 100
3000 ms 4640 KB
#include "circuit.h"
#include<bits/stdc++.h>
#include "circuit.h"
using namespace std;
#define vi vector<int>
#define vii vector<vi>
#define ll long long
#define vl vector<ll>
#include <cassert>
#include <cstdio>

int n,m;
vii g;
vl ways;
vl wb;
ll mod=1000002022;

ll sum(ll a, ll b){
  return (a+b)%mod; 
}
ll diff(ll a, ll b){
  return(a-b+mod)%mod;
}
void init(int N, int M, std::vector<int> P, std::vector<int> A) {

  n=N;
  m=M;
  g.resize(N+M);
  ways.resize(M+N);
  wb.resize(M+N);
  for(int i=1   ;i<N+M;i++){
    g[P[i]].push_back(i);
  }
  for(int i=N;i<N+M;i++){
    ways[i]=A[i-N];
    wb[i]=!ways[i];
  }

}

void dfs(int node){

  for(int child:g[node]){
    if(child>=n)continue;
    dfs(child);
  }

  int p=g[node].size();
  vl v(p+1);
  v[0]=1;

  for(int child:g[node]){
    vl copy(p+1);
    for(int i=0;i<=p;i++){
      if(i<p){
        copy[i+1]+=v[i+1]*wb[child]+v[i]*ways[child];
        copy[i+1]%=mod;
      }   
    }
    copy[0]=v[0]*wb[child];
    copy[0]%=mod;
    v=copy;
  }
  vl cum(p+1);
  cum[0]=v[0];
  for(int i=1;i<=p;i++){
    cum[i]=sum(cum[i-1],v[i]);
  }
  wb[node]=0;
  ways[node]=0;
  for(int i=1;i<=p;i++){
    wb[node]+=cum[i-1];
    wb[node]%=mod;
    ways[node]+=diff(cum[p],cum[i-1]);
    ways[node]%=mod;
  }
}

int count_ways(int L, int R) {

  for(int i=L;i<=R;i++){
    ways[i]=!ways[i];
    wb[i]=!wb[i];
  }

  dfs(0);
  return ways[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 22 ms 360 KB Output is correct
4 Correct 23 ms 356 KB Output is correct
5 Correct 23 ms 372 KB Output is correct
6 Correct 23 ms 360 KB Output is correct
7 Correct 23 ms 336 KB Output is correct
8 Correct 23 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 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 336 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 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 22 ms 360 KB Output is correct
4 Correct 23 ms 356 KB Output is correct
5 Correct 23 ms 372 KB Output is correct
6 Correct 23 ms 360 KB Output is correct
7 Correct 23 ms 336 KB Output is correct
8 Correct 23 ms 360 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 464 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 23 ms 368 KB Output is correct
30 Correct 23 ms 364 KB Output is correct
31 Correct 1 ms 464 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 5 ms 336 KB Output is correct
36 Correct 1 ms 464 KB Output is correct
37 Correct 23 ms 592 KB Output is correct
38 Correct 23 ms 592 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3094 ms 4640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3094 ms 4640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 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 336 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 336 KB Output is correct
13 Execution timed out 3094 ms 4640 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 22 ms 360 KB Output is correct
4 Correct 23 ms 356 KB Output is correct
5 Correct 23 ms 372 KB Output is correct
6 Correct 23 ms 360 KB Output is correct
7 Correct 23 ms 336 KB Output is correct
8 Correct 23 ms 360 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 464 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 23 ms 368 KB Output is correct
30 Correct 23 ms 364 KB Output is correct
31 Correct 1 ms 464 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 5 ms 336 KB Output is correct
36 Correct 1 ms 464 KB Output is correct
37 Correct 23 ms 592 KB Output is correct
38 Correct 23 ms 592 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 2 ms 336 KB Output is correct
43 Execution timed out 3008 ms 592 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 22 ms 360 KB Output is correct
4 Correct 23 ms 356 KB Output is correct
5 Correct 23 ms 372 KB Output is correct
6 Correct 23 ms 360 KB Output is correct
7 Correct 23 ms 336 KB Output is correct
8 Correct 23 ms 360 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 464 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 23 ms 368 KB Output is correct
30 Correct 23 ms 364 KB Output is correct
31 Correct 1 ms 464 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 5 ms 336 KB Output is correct
36 Correct 1 ms 464 KB Output is correct
37 Correct 23 ms 592 KB Output is correct
38 Correct 23 ms 592 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 2 ms 336 KB Output is correct
43 Execution timed out 3094 ms 4640 KB Time limit exceeded
44 Halted 0 ms 0 KB -