답안 #914523

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914523 2024-01-22T10:01:47 Z cig32 디지털 회로 (IOI22_circuit) C++17
46 / 100
3000 ms 13144 KB
#include "circuit.h"
#include "bits/stdc++.h"
using namespace std;
#define int long long

#include <vector>

const int MAXN = 2e5 + 12;
const int MOD = 1e9 + 2022;
int n, m;
vector<int> adj[MAXN];
int contrib[MAXN];
int ans;
int a[MAXN];
int lazy[MAXN];
int Y[MAXN];
void calc_y(int node) {
  Y[node] = adj[node].size();
  Y[node] = max(1ll, Y[node]);
  for(int x: adj[node]) {
    calc_y(x);
    Y[node] *= Y[x];
    Y[node] %= MOD;
  }
}
void propagate(int node) {
  for(int x: adj[node]) {
    lazy[x] *= lazy[node];
    lazy[x] %= MOD;
    propagate(x);
  }
}
void init(int32_t N, int32_t M, std::vector<int32_t> P, std::vector<int32_t> A) {
  for(int i=0; i<M; i++) contrib[i] = 1;
  for(int i=1; i<N+M; i++) adj[P[i]].push_back(i);
  for(int i=0; i<M; i++) a[i] = A[i];
  n = N;
  m = M;
  ans = 0;
  calc_y(0);
  for(int i=0; i<N+M; i++) lazy[i] = 1;
  for(int i=0; i<N; i++) {
    for(int x: adj[i]) {
      for(int y: adj[i]) {
        if(x != y) {
          lazy[y] *= Y[x];
          lazy[y] %= MOD;
        }
      }
    }
  }
  propagate(0);
  for(int i=0; i<N+M; i++) {
    contrib[i] = lazy[i];
  }
  
}

int32_t count_ways(int32_t L, int32_t R) {
  L -= n;
  R -= n;
  for(int i=L; i<=R; i++) {
    a[i] ^= 1;
  }
  int ans = 0;
  for(int i=0; i<m; i++) {
    if(a[i]) ans = (ans + contrib[n+i]) % MOD;
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11096 KB Output is correct
2 Correct 3 ms 11096 KB Output is correct
3 Correct 4 ms 11096 KB Output is correct
4 Correct 4 ms 11096 KB Output is correct
5 Correct 4 ms 11096 KB Output is correct
6 Correct 4 ms 11096 KB Output is correct
7 Correct 5 ms 11096 KB Output is correct
8 Correct 5 ms 11260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11096 KB Output is correct
2 Correct 3 ms 11096 KB Output is correct
3 Correct 3 ms 11096 KB Output is correct
4 Correct 2 ms 11096 KB Output is correct
5 Correct 3 ms 11096 KB Output is correct
6 Correct 3 ms 11096 KB Output is correct
7 Correct 3 ms 11096 KB Output is correct
8 Correct 3 ms 11096 KB Output is correct
9 Correct 3 ms 11096 KB Output is correct
10 Correct 3 ms 11096 KB Output is correct
11 Correct 3 ms 11352 KB Output is correct
12 Correct 3 ms 11096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11096 KB Output is correct
2 Correct 3 ms 11096 KB Output is correct
3 Correct 4 ms 11096 KB Output is correct
4 Correct 4 ms 11096 KB Output is correct
5 Correct 4 ms 11096 KB Output is correct
6 Correct 4 ms 11096 KB Output is correct
7 Correct 5 ms 11096 KB Output is correct
8 Correct 5 ms 11260 KB Output is correct
9 Correct 3 ms 11096 KB Output is correct
10 Correct 3 ms 11096 KB Output is correct
11 Correct 3 ms 11096 KB Output is correct
12 Correct 2 ms 11096 KB Output is correct
13 Correct 3 ms 11096 KB Output is correct
14 Correct 3 ms 11096 KB Output is correct
15 Correct 3 ms 11096 KB Output is correct
16 Correct 3 ms 11096 KB Output is correct
17 Correct 3 ms 11096 KB Output is correct
18 Correct 3 ms 11096 KB Output is correct
19 Correct 3 ms 11352 KB Output is correct
20 Correct 3 ms 11096 KB Output is correct
21 Correct 3 ms 11096 KB Output is correct
22 Correct 3 ms 11096 KB Output is correct
23 Correct 3 ms 11096 KB Output is correct
24 Correct 3 ms 11096 KB Output is correct
25 Correct 4 ms 11096 KB Output is correct
26 Correct 3 ms 11096 KB Output is correct
27 Correct 3 ms 11220 KB Output is correct
28 Correct 3 ms 11096 KB Output is correct
29 Correct 4 ms 11096 KB Output is correct
30 Correct 4 ms 11096 KB Output is correct
31 Correct 4 ms 11096 KB Output is correct
32 Correct 3 ms 11104 KB Output is correct
33 Correct 3 ms 11096 KB Output is correct
34 Correct 3 ms 11096 KB Output is correct
35 Correct 3 ms 11096 KB Output is correct
36 Correct 3 ms 11352 KB Output is correct
37 Correct 5 ms 11352 KB Output is correct
38 Correct 4 ms 11352 KB Output is correct
39 Correct 3 ms 11096 KB Output is correct
40 Correct 3 ms 11096 KB Output is correct
41 Correct 3 ms 11096 KB Output is correct
42 Correct 3 ms 11096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 13144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 13144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11096 KB Output is correct
2 Correct 3 ms 11096 KB Output is correct
3 Correct 3 ms 11096 KB Output is correct
4 Correct 2 ms 11096 KB Output is correct
5 Correct 3 ms 11096 KB Output is correct
6 Correct 3 ms 11096 KB Output is correct
7 Correct 3 ms 11096 KB Output is correct
8 Correct 3 ms 11096 KB Output is correct
9 Correct 3 ms 11096 KB Output is correct
10 Correct 3 ms 11096 KB Output is correct
11 Correct 3 ms 11352 KB Output is correct
12 Correct 3 ms 11096 KB Output is correct
13 Execution timed out 3064 ms 13144 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11096 KB Output is correct
2 Correct 3 ms 11096 KB Output is correct
3 Correct 4 ms 11096 KB Output is correct
4 Correct 4 ms 11096 KB Output is correct
5 Correct 4 ms 11096 KB Output is correct
6 Correct 4 ms 11096 KB Output is correct
7 Correct 5 ms 11096 KB Output is correct
8 Correct 5 ms 11260 KB Output is correct
9 Correct 3 ms 11096 KB Output is correct
10 Correct 3 ms 11096 KB Output is correct
11 Correct 3 ms 11096 KB Output is correct
12 Correct 2 ms 11096 KB Output is correct
13 Correct 3 ms 11096 KB Output is correct
14 Correct 3 ms 11096 KB Output is correct
15 Correct 3 ms 11096 KB Output is correct
16 Correct 3 ms 11096 KB Output is correct
17 Correct 3 ms 11096 KB Output is correct
18 Correct 3 ms 11096 KB Output is correct
19 Correct 3 ms 11352 KB Output is correct
20 Correct 3 ms 11096 KB Output is correct
21 Correct 3 ms 11096 KB Output is correct
22 Correct 3 ms 11096 KB Output is correct
23 Correct 3 ms 11096 KB Output is correct
24 Correct 3 ms 11096 KB Output is correct
25 Correct 4 ms 11096 KB Output is correct
26 Correct 3 ms 11096 KB Output is correct
27 Correct 3 ms 11220 KB Output is correct
28 Correct 3 ms 11096 KB Output is correct
29 Correct 4 ms 11096 KB Output is correct
30 Correct 4 ms 11096 KB Output is correct
31 Correct 4 ms 11096 KB Output is correct
32 Correct 3 ms 11104 KB Output is correct
33 Correct 3 ms 11096 KB Output is correct
34 Correct 3 ms 11096 KB Output is correct
35 Correct 3 ms 11096 KB Output is correct
36 Correct 3 ms 11352 KB Output is correct
37 Correct 5 ms 11352 KB Output is correct
38 Correct 4 ms 11352 KB Output is correct
39 Correct 3 ms 11096 KB Output is correct
40 Correct 3 ms 11096 KB Output is correct
41 Correct 3 ms 11096 KB Output is correct
42 Correct 3 ms 11096 KB Output is correct
43 Correct 872 ms 11352 KB Output is correct
44 Correct 1116 ms 11604 KB Output is correct
45 Correct 1304 ms 11352 KB Output is correct
46 Correct 1513 ms 11352 KB Output is correct
47 Correct 2045 ms 11352 KB Output is correct
48 Correct 2113 ms 11352 KB Output is correct
49 Correct 2091 ms 11604 KB Output is correct
50 Correct 1524 ms 11352 KB Output is correct
51 Correct 2322 ms 11424 KB Output is correct
52 Correct 2077 ms 11420 KB Output is correct
53 Correct 463 ms 11764 KB Output is correct
54 Correct 2066 ms 11352 KB Output is correct
55 Correct 2089 ms 11352 KB Output is correct
56 Correct 2094 ms 11352 KB Output is correct
57 Correct 2025 ms 11352 KB Output is correct
58 Correct 2069 ms 11864 KB Output is correct
59 Correct 2068 ms 11960 KB Output is correct
60 Correct 2281 ms 11964 KB Output is correct
61 Correct 1047 ms 11604 KB Output is correct
62 Correct 1416 ms 11352 KB Output is correct
63 Correct 1533 ms 11352 KB Output is correct
64 Correct 2025 ms 11352 KB Output is correct
65 Correct 503 ms 11352 KB Output is correct
66 Correct 1670 ms 11352 KB Output is correct
67 Correct 1646 ms 11352 KB Output is correct
68 Correct 1718 ms 11352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11096 KB Output is correct
2 Correct 3 ms 11096 KB Output is correct
3 Correct 4 ms 11096 KB Output is correct
4 Correct 4 ms 11096 KB Output is correct
5 Correct 4 ms 11096 KB Output is correct
6 Correct 4 ms 11096 KB Output is correct
7 Correct 5 ms 11096 KB Output is correct
8 Correct 5 ms 11260 KB Output is correct
9 Correct 3 ms 11096 KB Output is correct
10 Correct 3 ms 11096 KB Output is correct
11 Correct 3 ms 11096 KB Output is correct
12 Correct 2 ms 11096 KB Output is correct
13 Correct 3 ms 11096 KB Output is correct
14 Correct 3 ms 11096 KB Output is correct
15 Correct 3 ms 11096 KB Output is correct
16 Correct 3 ms 11096 KB Output is correct
17 Correct 3 ms 11096 KB Output is correct
18 Correct 3 ms 11096 KB Output is correct
19 Correct 3 ms 11352 KB Output is correct
20 Correct 3 ms 11096 KB Output is correct
21 Correct 3 ms 11096 KB Output is correct
22 Correct 3 ms 11096 KB Output is correct
23 Correct 3 ms 11096 KB Output is correct
24 Correct 3 ms 11096 KB Output is correct
25 Correct 4 ms 11096 KB Output is correct
26 Correct 3 ms 11096 KB Output is correct
27 Correct 3 ms 11220 KB Output is correct
28 Correct 3 ms 11096 KB Output is correct
29 Correct 4 ms 11096 KB Output is correct
30 Correct 4 ms 11096 KB Output is correct
31 Correct 4 ms 11096 KB Output is correct
32 Correct 3 ms 11104 KB Output is correct
33 Correct 3 ms 11096 KB Output is correct
34 Correct 3 ms 11096 KB Output is correct
35 Correct 3 ms 11096 KB Output is correct
36 Correct 3 ms 11352 KB Output is correct
37 Correct 5 ms 11352 KB Output is correct
38 Correct 4 ms 11352 KB Output is correct
39 Correct 3 ms 11096 KB Output is correct
40 Correct 3 ms 11096 KB Output is correct
41 Correct 3 ms 11096 KB Output is correct
42 Correct 3 ms 11096 KB Output is correct
43 Execution timed out 3064 ms 13144 KB Time limit exceeded
44 Halted 0 ms 0 KB -