답안 #830943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
830943 2023-08-19T13:25:01 Z beaconmc 디지털 회로 (IOI22_circuit) C++17
46 / 100
3000 ms 6316 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];
ll dps[100001];
vector<int> p;
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;
}

int dp(ll a){
  if (a==0) return 1;
  if (dps[a] != -1) return dps[a];

  ll temp = 1;

  for (auto&i : edges[p[a]]){
    if (i != a) temp *= possible[i];
    temp %= 1000002022;
  }
  dps[a] = temp * dp(p[a]) % 1000002022;
  return dps[a];
}

ll n,m;

void init(int N, int M, std::vector<int> P, std::vector<int> A) {
  FOR(i,0,100001) dps[i] = -1;
  p = P;
  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 = possible[i];
    temp *= dp(i);
    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 3408 KB Output is correct
2 Correct 2 ms 3408 KB Output is correct
3 Correct 6 ms 3408 KB Output is correct
4 Correct 6 ms 3408 KB Output is correct
5 Correct 6 ms 3408 KB Output is correct
6 Correct 6 ms 3408 KB Output is correct
7 Correct 6 ms 3408 KB Output is correct
8 Correct 6 ms 3408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3408 KB Output is correct
2 Correct 3 ms 3408 KB Output is correct
3 Correct 2 ms 3408 KB Output is correct
4 Correct 2 ms 3408 KB Output is correct
5 Correct 2 ms 3408 KB Output is correct
6 Correct 2 ms 3408 KB Output is correct
7 Correct 2 ms 3536 KB Output is correct
8 Correct 2 ms 3536 KB Output is correct
9 Correct 2 ms 3536 KB Output is correct
10 Correct 2 ms 3536 KB Output is correct
11 Correct 2 ms 3536 KB Output is correct
12 Correct 2 ms 3408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3408 KB Output is correct
2 Correct 2 ms 3408 KB Output is correct
3 Correct 6 ms 3408 KB Output is correct
4 Correct 6 ms 3408 KB Output is correct
5 Correct 6 ms 3408 KB Output is correct
6 Correct 6 ms 3408 KB Output is correct
7 Correct 6 ms 3408 KB Output is correct
8 Correct 6 ms 3408 KB Output is correct
9 Correct 1 ms 3408 KB Output is correct
10 Correct 3 ms 3408 KB Output is correct
11 Correct 2 ms 3408 KB Output is correct
12 Correct 2 ms 3408 KB Output is correct
13 Correct 2 ms 3408 KB Output is correct
14 Correct 2 ms 3408 KB Output is correct
15 Correct 2 ms 3536 KB Output is correct
16 Correct 2 ms 3536 KB Output is correct
17 Correct 2 ms 3536 KB Output is correct
18 Correct 2 ms 3536 KB Output is correct
19 Correct 2 ms 3536 KB Output is correct
20 Correct 2 ms 3408 KB Output is correct
21 Correct 2 ms 3476 KB Output is correct
22 Correct 2 ms 3408 KB Output is correct
23 Correct 2 ms 3408 KB Output is correct
24 Correct 2 ms 3536 KB Output is correct
25 Correct 2 ms 3536 KB Output is correct
26 Correct 2 ms 3536 KB Output is correct
27 Correct 2 ms 3536 KB Output is correct
28 Correct 2 ms 3536 KB Output is correct
29 Correct 6 ms 3408 KB Output is correct
30 Correct 6 ms 3408 KB Output is correct
31 Correct 2 ms 3536 KB Output is correct
32 Correct 2 ms 3536 KB Output is correct
33 Correct 2 ms 3408 KB Output is correct
34 Correct 2 ms 3408 KB Output is correct
35 Correct 2 ms 3488 KB Output is correct
36 Correct 2 ms 3536 KB Output is correct
37 Correct 6 ms 3536 KB Output is correct
38 Correct 6 ms 3536 KB Output is correct
39 Correct 2 ms 3408 KB Output is correct
40 Correct 2 ms 3408 KB Output is correct
41 Correct 2 ms 3408 KB Output is correct
42 Correct 2 ms 3408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3049 ms 6316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3049 ms 6316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3408 KB Output is correct
2 Correct 3 ms 3408 KB Output is correct
3 Correct 2 ms 3408 KB Output is correct
4 Correct 2 ms 3408 KB Output is correct
5 Correct 2 ms 3408 KB Output is correct
6 Correct 2 ms 3408 KB Output is correct
7 Correct 2 ms 3536 KB Output is correct
8 Correct 2 ms 3536 KB Output is correct
9 Correct 2 ms 3536 KB Output is correct
10 Correct 2 ms 3536 KB Output is correct
11 Correct 2 ms 3536 KB Output is correct
12 Correct 2 ms 3408 KB Output is correct
13 Execution timed out 3049 ms 6316 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3408 KB Output is correct
2 Correct 2 ms 3408 KB Output is correct
3 Correct 6 ms 3408 KB Output is correct
4 Correct 6 ms 3408 KB Output is correct
5 Correct 6 ms 3408 KB Output is correct
6 Correct 6 ms 3408 KB Output is correct
7 Correct 6 ms 3408 KB Output is correct
8 Correct 6 ms 3408 KB Output is correct
9 Correct 1 ms 3408 KB Output is correct
10 Correct 3 ms 3408 KB Output is correct
11 Correct 2 ms 3408 KB Output is correct
12 Correct 2 ms 3408 KB Output is correct
13 Correct 2 ms 3408 KB Output is correct
14 Correct 2 ms 3408 KB Output is correct
15 Correct 2 ms 3536 KB Output is correct
16 Correct 2 ms 3536 KB Output is correct
17 Correct 2 ms 3536 KB Output is correct
18 Correct 2 ms 3536 KB Output is correct
19 Correct 2 ms 3536 KB Output is correct
20 Correct 2 ms 3408 KB Output is correct
21 Correct 2 ms 3476 KB Output is correct
22 Correct 2 ms 3408 KB Output is correct
23 Correct 2 ms 3408 KB Output is correct
24 Correct 2 ms 3536 KB Output is correct
25 Correct 2 ms 3536 KB Output is correct
26 Correct 2 ms 3536 KB Output is correct
27 Correct 2 ms 3536 KB Output is correct
28 Correct 2 ms 3536 KB Output is correct
29 Correct 6 ms 3408 KB Output is correct
30 Correct 6 ms 3408 KB Output is correct
31 Correct 2 ms 3536 KB Output is correct
32 Correct 2 ms 3536 KB Output is correct
33 Correct 2 ms 3408 KB Output is correct
34 Correct 2 ms 3408 KB Output is correct
35 Correct 2 ms 3488 KB Output is correct
36 Correct 2 ms 3536 KB Output is correct
37 Correct 6 ms 3536 KB Output is correct
38 Correct 6 ms 3536 KB Output is correct
39 Correct 2 ms 3408 KB Output is correct
40 Correct 2 ms 3408 KB Output is correct
41 Correct 2 ms 3408 KB Output is correct
42 Correct 2 ms 3408 KB Output is correct
43 Correct 978 ms 3664 KB Output is correct
44 Correct 1276 ms 3664 KB Output is correct
45 Correct 1243 ms 3664 KB Output is correct
46 Correct 1351 ms 3792 KB Output is correct
47 Correct 2268 ms 3792 KB Output is correct
48 Correct 2049 ms 3920 KB Output is correct
49 Correct 1965 ms 3920 KB Output is correct
50 Correct 1296 ms 3792 KB Output is correct
51 Correct 2524 ms 3716 KB Output is correct
52 Correct 2257 ms 3716 KB Output is correct
53 Correct 594 ms 3920 KB Output is correct
54 Correct 2249 ms 3792 KB Output is correct
55 Correct 2270 ms 3792 KB Output is correct
56 Correct 2185 ms 3664 KB Output is correct
57 Correct 1973 ms 3664 KB Output is correct
58 Correct 2094 ms 4176 KB Output is correct
59 Correct 2102 ms 4304 KB Output is correct
60 Correct 2532 ms 4288 KB Output is correct
61 Correct 1274 ms 3792 KB Output is correct
62 Correct 1770 ms 3664 KB Output is correct
63 Correct 1581 ms 3664 KB Output is correct
64 Correct 2255 ms 3664 KB Output is correct
65 Correct 577 ms 3536 KB Output is correct
66 Correct 1877 ms 3792 KB Output is correct
67 Correct 1797 ms 3792 KB Output is correct
68 Correct 1833 ms 3792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3408 KB Output is correct
2 Correct 2 ms 3408 KB Output is correct
3 Correct 6 ms 3408 KB Output is correct
4 Correct 6 ms 3408 KB Output is correct
5 Correct 6 ms 3408 KB Output is correct
6 Correct 6 ms 3408 KB Output is correct
7 Correct 6 ms 3408 KB Output is correct
8 Correct 6 ms 3408 KB Output is correct
9 Correct 1 ms 3408 KB Output is correct
10 Correct 3 ms 3408 KB Output is correct
11 Correct 2 ms 3408 KB Output is correct
12 Correct 2 ms 3408 KB Output is correct
13 Correct 2 ms 3408 KB Output is correct
14 Correct 2 ms 3408 KB Output is correct
15 Correct 2 ms 3536 KB Output is correct
16 Correct 2 ms 3536 KB Output is correct
17 Correct 2 ms 3536 KB Output is correct
18 Correct 2 ms 3536 KB Output is correct
19 Correct 2 ms 3536 KB Output is correct
20 Correct 2 ms 3408 KB Output is correct
21 Correct 2 ms 3476 KB Output is correct
22 Correct 2 ms 3408 KB Output is correct
23 Correct 2 ms 3408 KB Output is correct
24 Correct 2 ms 3536 KB Output is correct
25 Correct 2 ms 3536 KB Output is correct
26 Correct 2 ms 3536 KB Output is correct
27 Correct 2 ms 3536 KB Output is correct
28 Correct 2 ms 3536 KB Output is correct
29 Correct 6 ms 3408 KB Output is correct
30 Correct 6 ms 3408 KB Output is correct
31 Correct 2 ms 3536 KB Output is correct
32 Correct 2 ms 3536 KB Output is correct
33 Correct 2 ms 3408 KB Output is correct
34 Correct 2 ms 3408 KB Output is correct
35 Correct 2 ms 3488 KB Output is correct
36 Correct 2 ms 3536 KB Output is correct
37 Correct 6 ms 3536 KB Output is correct
38 Correct 6 ms 3536 KB Output is correct
39 Correct 2 ms 3408 KB Output is correct
40 Correct 2 ms 3408 KB Output is correct
41 Correct 2 ms 3408 KB Output is correct
42 Correct 2 ms 3408 KB Output is correct
43 Execution timed out 3049 ms 6316 KB Time limit exceeded
44 Halted 0 ms 0 KB -