답안 #830833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
830833 2023-08-19T11:07:49 Z beaconmc 디지털 회로 (IOI22_circuit) C++17
46 / 100
3000 ms 5212 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 contrib[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;
}

ll n,m;

void init(int N, int M, std::vector<int> P, std::vector<int> A) {
  n = N;
  m = M;
  FOR(i,1,N+M){
    edges[P[i]].push_back(i);
  }
  FOR(i,N,N+M){
    state[i] = A[i-N];
  }
  initdfs(0);


  FOR(i,N,N+M){
    ll temp = 1;
    ll cur = i;
    while (cur != 0){

      for (auto&j : edges[P[cur]]){
        if (j!= cur) temp *= possible[j];
        temp %= 1000002022;
      }
      cur = P[cur];
      
    }
    contrib[i] = temp%1000002022;
  }

}


int count_ways(int L, int R) {
  FOR(i,L,R+1){
    state[i] = (state[i]+1)%2;
  }
  ll ans = 0;

  FOR(i,n,n+m){
    if (state[i]) ans += contrib[i];
  }
  return ans%1000002022;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 6 ms 2640 KB Output is correct
4 Correct 6 ms 2640 KB Output is correct
5 Correct 5 ms 2640 KB Output is correct
6 Correct 6 ms 2596 KB Output is correct
7 Correct 5 ms 2640 KB Output is correct
8 Correct 5 ms 2696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 1 ms 2640 KB Output is correct
5 Correct 2 ms 2640 KB Output is correct
6 Correct 2 ms 2640 KB Output is correct
7 Correct 3 ms 2640 KB Output is correct
8 Correct 2 ms 2640 KB Output is correct
9 Correct 2 ms 2640 KB Output is correct
10 Correct 5 ms 2768 KB Output is correct
11 Correct 5 ms 2768 KB Output is correct
12 Correct 2 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 6 ms 2640 KB Output is correct
4 Correct 6 ms 2640 KB Output is correct
5 Correct 5 ms 2640 KB Output is correct
6 Correct 6 ms 2596 KB Output is correct
7 Correct 5 ms 2640 KB Output is correct
8 Correct 5 ms 2696 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2640 KB Output is correct
11 Correct 2 ms 2640 KB Output is correct
12 Correct 1 ms 2640 KB Output is correct
13 Correct 2 ms 2640 KB Output is correct
14 Correct 2 ms 2640 KB Output is correct
15 Correct 3 ms 2640 KB Output is correct
16 Correct 2 ms 2640 KB Output is correct
17 Correct 2 ms 2640 KB Output is correct
18 Correct 5 ms 2768 KB Output is correct
19 Correct 5 ms 2768 KB Output is correct
20 Correct 2 ms 2640 KB Output is correct
21 Correct 2 ms 2640 KB Output is correct
22 Correct 1 ms 2640 KB Output is correct
23 Correct 2 ms 2640 KB Output is correct
24 Correct 2 ms 2640 KB Output is correct
25 Correct 2 ms 2640 KB Output is correct
26 Correct 2 ms 2640 KB Output is correct
27 Correct 2 ms 2640 KB Output is correct
28 Correct 2 ms 2640 KB Output is correct
29 Correct 5 ms 2640 KB Output is correct
30 Correct 5 ms 2704 KB Output is correct
31 Correct 1 ms 2768 KB Output is correct
32 Correct 2 ms 2640 KB Output is correct
33 Correct 2 ms 2640 KB Output is correct
34 Correct 2 ms 2640 KB Output is correct
35 Correct 3 ms 2640 KB Output is correct
36 Correct 5 ms 2768 KB Output is correct
37 Correct 9 ms 2768 KB Output is correct
38 Correct 9 ms 2768 KB Output is correct
39 Correct 2 ms 2640 KB Output is correct
40 Correct 2 ms 2640 KB Output is correct
41 Correct 2 ms 2640 KB Output is correct
42 Correct 2 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3092 ms 5212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3092 ms 5212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 1 ms 2640 KB Output is correct
5 Correct 2 ms 2640 KB Output is correct
6 Correct 2 ms 2640 KB Output is correct
7 Correct 3 ms 2640 KB Output is correct
8 Correct 2 ms 2640 KB Output is correct
9 Correct 2 ms 2640 KB Output is correct
10 Correct 5 ms 2768 KB Output is correct
11 Correct 5 ms 2768 KB Output is correct
12 Correct 2 ms 2640 KB Output is correct
13 Execution timed out 3092 ms 5212 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 6 ms 2640 KB Output is correct
4 Correct 6 ms 2640 KB Output is correct
5 Correct 5 ms 2640 KB Output is correct
6 Correct 6 ms 2596 KB Output is correct
7 Correct 5 ms 2640 KB Output is correct
8 Correct 5 ms 2696 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2640 KB Output is correct
11 Correct 2 ms 2640 KB Output is correct
12 Correct 1 ms 2640 KB Output is correct
13 Correct 2 ms 2640 KB Output is correct
14 Correct 2 ms 2640 KB Output is correct
15 Correct 3 ms 2640 KB Output is correct
16 Correct 2 ms 2640 KB Output is correct
17 Correct 2 ms 2640 KB Output is correct
18 Correct 5 ms 2768 KB Output is correct
19 Correct 5 ms 2768 KB Output is correct
20 Correct 2 ms 2640 KB Output is correct
21 Correct 2 ms 2640 KB Output is correct
22 Correct 1 ms 2640 KB Output is correct
23 Correct 2 ms 2640 KB Output is correct
24 Correct 2 ms 2640 KB Output is correct
25 Correct 2 ms 2640 KB Output is correct
26 Correct 2 ms 2640 KB Output is correct
27 Correct 2 ms 2640 KB Output is correct
28 Correct 2 ms 2640 KB Output is correct
29 Correct 5 ms 2640 KB Output is correct
30 Correct 5 ms 2704 KB Output is correct
31 Correct 1 ms 2768 KB Output is correct
32 Correct 2 ms 2640 KB Output is correct
33 Correct 2 ms 2640 KB Output is correct
34 Correct 2 ms 2640 KB Output is correct
35 Correct 3 ms 2640 KB Output is correct
36 Correct 5 ms 2768 KB Output is correct
37 Correct 9 ms 2768 KB Output is correct
38 Correct 9 ms 2768 KB Output is correct
39 Correct 2 ms 2640 KB Output is correct
40 Correct 2 ms 2640 KB Output is correct
41 Correct 2 ms 2640 KB Output is correct
42 Correct 2 ms 2640 KB Output is correct
43 Correct 1142 ms 2784 KB Output is correct
44 Correct 1462 ms 2904 KB Output is correct
45 Correct 1587 ms 2892 KB Output is correct
46 Correct 1804 ms 3032 KB Output is correct
47 Correct 2389 ms 3024 KB Output is correct
48 Correct 2301 ms 2960 KB Output is correct
49 Correct 2247 ms 3024 KB Output is correct
50 Correct 1334 ms 3024 KB Output is correct
51 Correct 2746 ms 2908 KB Output is correct
52 Correct 2355 ms 2908 KB Output is correct
53 Correct 574 ms 3152 KB Output is correct
54 Correct 2056 ms 3020 KB Output is correct
55 Correct 2415 ms 2892 KB Output is correct
56 Correct 2294 ms 2900 KB Output is correct
57 Correct 2025 ms 2836 KB Output is correct
58 Correct 2319 ms 3284 KB Output is correct
59 Correct 2403 ms 3536 KB Output is correct
60 Correct 2595 ms 3456 KB Output is correct
61 Correct 1253 ms 2896 KB Output is correct
62 Correct 1625 ms 2768 KB Output is correct
63 Correct 1886 ms 2772 KB Output is correct
64 Correct 2321 ms 2780 KB Output is correct
65 Correct 620 ms 2776 KB Output is correct
66 Correct 1691 ms 2932 KB Output is correct
67 Correct 1792 ms 2900 KB Output is correct
68 Correct 2035 ms 2896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 6 ms 2640 KB Output is correct
4 Correct 6 ms 2640 KB Output is correct
5 Correct 5 ms 2640 KB Output is correct
6 Correct 6 ms 2596 KB Output is correct
7 Correct 5 ms 2640 KB Output is correct
8 Correct 5 ms 2696 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2640 KB Output is correct
11 Correct 2 ms 2640 KB Output is correct
12 Correct 1 ms 2640 KB Output is correct
13 Correct 2 ms 2640 KB Output is correct
14 Correct 2 ms 2640 KB Output is correct
15 Correct 3 ms 2640 KB Output is correct
16 Correct 2 ms 2640 KB Output is correct
17 Correct 2 ms 2640 KB Output is correct
18 Correct 5 ms 2768 KB Output is correct
19 Correct 5 ms 2768 KB Output is correct
20 Correct 2 ms 2640 KB Output is correct
21 Correct 2 ms 2640 KB Output is correct
22 Correct 1 ms 2640 KB Output is correct
23 Correct 2 ms 2640 KB Output is correct
24 Correct 2 ms 2640 KB Output is correct
25 Correct 2 ms 2640 KB Output is correct
26 Correct 2 ms 2640 KB Output is correct
27 Correct 2 ms 2640 KB Output is correct
28 Correct 2 ms 2640 KB Output is correct
29 Correct 5 ms 2640 KB Output is correct
30 Correct 5 ms 2704 KB Output is correct
31 Correct 1 ms 2768 KB Output is correct
32 Correct 2 ms 2640 KB Output is correct
33 Correct 2 ms 2640 KB Output is correct
34 Correct 2 ms 2640 KB Output is correct
35 Correct 3 ms 2640 KB Output is correct
36 Correct 5 ms 2768 KB Output is correct
37 Correct 9 ms 2768 KB Output is correct
38 Correct 9 ms 2768 KB Output is correct
39 Correct 2 ms 2640 KB Output is correct
40 Correct 2 ms 2640 KB Output is correct
41 Correct 2 ms 2640 KB Output is correct
42 Correct 2 ms 2640 KB Output is correct
43 Execution timed out 3092 ms 5212 KB Time limit exceeded
44 Halted 0 ms 0 KB -