#include "circuit.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1'000'002'022;
int n, m;
vector<ll> storage;
vector<int> a;
void init(int N, int M, std::vector<int> P, std::vector<int> A) {
n = N;
m = M;
vector<ll> degrees(N, 0);
for (int i=1; i<(N+M); i++)
degrees[P[i]]++;
vector<vector<bool>> ancestor(N+M, vector<bool> (N, 0));
for (int i=1; i<(N+M); i++)
{
int par = P[i];
for (int j=0; j<N; j++)
ancestor[i][j] = ancestor[par][j];
ancestor[i][par] = 1;
}
for (int i=N; i<(N+M); i++)
{
a.push_back(A[i-N]);
ll ans = 1;
for (int j = 0; j<N; j++)
if (ancestor[i][j] == 0)
ans = (ans*degrees[j])%MOD;
storage.push_back(ans);
}
}
int count_ways(int L, int R) {
L -= n;
R -= n;
for (int i=L; i<=R; i++)
a[i] = 1-a[i];
ll total = 0;
for (int i=0; i<m; i++)
{
if (a[i]==1)
total = total+storage[i];
}
ll fa = total%MOD;
int ffa = fa;
return ffa;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
4 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
6 ms |
664 KB |
Output is correct |
7 |
Correct |
11 ms |
600 KB |
Output is correct |
8 |
Correct |
11 ms |
844 KB |
Output is correct |
9 |
Correct |
11 ms |
824 KB |
Output is correct |
10 |
Correct |
9 ms |
816 KB |
Output is correct |
11 |
Correct |
10 ms |
600 KB |
Output is correct |
12 |
Correct |
8 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
4 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
3 ms |
344 KB |
Output is correct |
14 |
Correct |
6 ms |
664 KB |
Output is correct |
15 |
Correct |
11 ms |
600 KB |
Output is correct |
16 |
Correct |
11 ms |
844 KB |
Output is correct |
17 |
Correct |
11 ms |
824 KB |
Output is correct |
18 |
Correct |
9 ms |
816 KB |
Output is correct |
19 |
Correct |
10 ms |
600 KB |
Output is correct |
20 |
Correct |
8 ms |
600 KB |
Output is correct |
21 |
Correct |
7 ms |
600 KB |
Output is correct |
22 |
Correct |
5 ms |
600 KB |
Output is correct |
23 |
Correct |
4 ms |
600 KB |
Output is correct |
24 |
Correct |
11 ms |
820 KB |
Output is correct |
25 |
Correct |
11 ms |
600 KB |
Output is correct |
26 |
Correct |
11 ms |
820 KB |
Output is correct |
27 |
Correct |
12 ms |
600 KB |
Output is correct |
28 |
Correct |
11 ms |
600 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
31 |
Correct |
3 ms |
600 KB |
Output is correct |
32 |
Correct |
11 ms |
600 KB |
Output is correct |
33 |
Correct |
5 ms |
528 KB |
Output is correct |
34 |
Correct |
3 ms |
344 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
10 ms |
828 KB |
Output is correct |
37 |
Correct |
8 ms |
600 KB |
Output is correct |
38 |
Correct |
8 ms |
824 KB |
Output is correct |
39 |
Correct |
4 ms |
600 KB |
Output is correct |
40 |
Correct |
5 ms |
600 KB |
Output is correct |
41 |
Correct |
4 ms |
344 KB |
Output is correct |
42 |
Correct |
1 ms |
516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3078 ms |
267600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3078 ms |
267600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
4 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
6 ms |
664 KB |
Output is correct |
7 |
Correct |
11 ms |
600 KB |
Output is correct |
8 |
Correct |
11 ms |
844 KB |
Output is correct |
9 |
Correct |
11 ms |
824 KB |
Output is correct |
10 |
Correct |
9 ms |
816 KB |
Output is correct |
11 |
Correct |
10 ms |
600 KB |
Output is correct |
12 |
Correct |
8 ms |
600 KB |
Output is correct |
13 |
Execution timed out |
3078 ms |
267600 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
4 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
3 ms |
344 KB |
Output is correct |
14 |
Correct |
6 ms |
664 KB |
Output is correct |
15 |
Correct |
11 ms |
600 KB |
Output is correct |
16 |
Correct |
11 ms |
844 KB |
Output is correct |
17 |
Correct |
11 ms |
824 KB |
Output is correct |
18 |
Correct |
9 ms |
816 KB |
Output is correct |
19 |
Correct |
10 ms |
600 KB |
Output is correct |
20 |
Correct |
8 ms |
600 KB |
Output is correct |
21 |
Correct |
7 ms |
600 KB |
Output is correct |
22 |
Correct |
5 ms |
600 KB |
Output is correct |
23 |
Correct |
4 ms |
600 KB |
Output is correct |
24 |
Correct |
11 ms |
820 KB |
Output is correct |
25 |
Correct |
11 ms |
600 KB |
Output is correct |
26 |
Correct |
11 ms |
820 KB |
Output is correct |
27 |
Correct |
12 ms |
600 KB |
Output is correct |
28 |
Correct |
11 ms |
600 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
31 |
Correct |
3 ms |
600 KB |
Output is correct |
32 |
Correct |
11 ms |
600 KB |
Output is correct |
33 |
Correct |
5 ms |
528 KB |
Output is correct |
34 |
Correct |
3 ms |
344 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
10 ms |
828 KB |
Output is correct |
37 |
Correct |
8 ms |
600 KB |
Output is correct |
38 |
Correct |
8 ms |
824 KB |
Output is correct |
39 |
Correct |
4 ms |
600 KB |
Output is correct |
40 |
Correct |
5 ms |
600 KB |
Output is correct |
41 |
Correct |
4 ms |
344 KB |
Output is correct |
42 |
Correct |
1 ms |
516 KB |
Output is correct |
43 |
Correct |
787 ms |
2896 KB |
Output is correct |
44 |
Correct |
1130 ms |
4184 KB |
Output is correct |
45 |
Correct |
1162 ms |
3664 KB |
Output is correct |
46 |
Correct |
1435 ms |
7248 KB |
Output is correct |
47 |
Correct |
1605 ms |
7312 KB |
Output is correct |
48 |
Correct |
1640 ms |
7248 KB |
Output is correct |
49 |
Correct |
1608 ms |
7244 KB |
Output is correct |
50 |
Correct |
1481 ms |
7248 KB |
Output is correct |
51 |
Correct |
1449 ms |
856 KB |
Output is correct |
52 |
Correct |
1327 ms |
856 KB |
Output is correct |
53 |
Correct |
747 ms |
3668 KB |
Output is correct |
54 |
Correct |
1622 ms |
7248 KB |
Output is correct |
55 |
Correct |
1427 ms |
3408 KB |
Output is correct |
56 |
Correct |
1375 ms |
1880 KB |
Output is correct |
57 |
Correct |
1308 ms |
856 KB |
Output is correct |
58 |
Correct |
1591 ms |
7248 KB |
Output is correct |
59 |
Correct |
1487 ms |
7244 KB |
Output is correct |
60 |
Correct |
1607 ms |
7240 KB |
Output is correct |
61 |
Correct |
1097 ms |
4072 KB |
Output is correct |
62 |
Correct |
1245 ms |
2384 KB |
Output is correct |
63 |
Correct |
1165 ms |
1624 KB |
Output is correct |
64 |
Correct |
1277 ms |
856 KB |
Output is correct |
65 |
Correct |
486 ms |
1624 KB |
Output is correct |
66 |
Correct |
1332 ms |
4952 KB |
Output is correct |
67 |
Correct |
1339 ms |
5116 KB |
Output is correct |
68 |
Correct |
1479 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
4 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
3 ms |
344 KB |
Output is correct |
14 |
Correct |
6 ms |
664 KB |
Output is correct |
15 |
Correct |
11 ms |
600 KB |
Output is correct |
16 |
Correct |
11 ms |
844 KB |
Output is correct |
17 |
Correct |
11 ms |
824 KB |
Output is correct |
18 |
Correct |
9 ms |
816 KB |
Output is correct |
19 |
Correct |
10 ms |
600 KB |
Output is correct |
20 |
Correct |
8 ms |
600 KB |
Output is correct |
21 |
Correct |
7 ms |
600 KB |
Output is correct |
22 |
Correct |
5 ms |
600 KB |
Output is correct |
23 |
Correct |
4 ms |
600 KB |
Output is correct |
24 |
Correct |
11 ms |
820 KB |
Output is correct |
25 |
Correct |
11 ms |
600 KB |
Output is correct |
26 |
Correct |
11 ms |
820 KB |
Output is correct |
27 |
Correct |
12 ms |
600 KB |
Output is correct |
28 |
Correct |
11 ms |
600 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
31 |
Correct |
3 ms |
600 KB |
Output is correct |
32 |
Correct |
11 ms |
600 KB |
Output is correct |
33 |
Correct |
5 ms |
528 KB |
Output is correct |
34 |
Correct |
3 ms |
344 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
10 ms |
828 KB |
Output is correct |
37 |
Correct |
8 ms |
600 KB |
Output is correct |
38 |
Correct |
8 ms |
824 KB |
Output is correct |
39 |
Correct |
4 ms |
600 KB |
Output is correct |
40 |
Correct |
5 ms |
600 KB |
Output is correct |
41 |
Correct |
4 ms |
344 KB |
Output is correct |
42 |
Correct |
1 ms |
516 KB |
Output is correct |
43 |
Execution timed out |
3078 ms |
267600 KB |
Time limit exceeded |
44 |
Halted |
0 ms |
0 KB |
- |