#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;
#define rall(s) s.rbegin(), s.rend()
#define all(s) s.begin(), s.end()
#define sz(s) (int) s.size()
#define s second
#define f first
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int N = 5e5, mod = 1000002022;
int n, m;
vector<int> g[N], a(N);
void init(int nn, int M, vector<int> P, vector<int> A) {
n = nn, m = M;
for (int i = 0; i < m; i++) a[i + n] = A[i];
for (int i = 1; i < n + m; i++) {
g[P[i]].push_back(i);
}
}
pii get(int u) {
if (!sz(g[u])) {
if (a[u]) return {1, 0};
return {0, 1};
}
int cnt = 0;
vector<ll> val(sz(g[u]) + 1);
val[0] = 1;
for (int to: g[u]) {
cnt++;
auto [x, y] = get(to);
for (int i = cnt; i >= 0; i--) {
val[i] = (val[i] * y) % mod;
if (i) val[i] = (val[i] + val[i - 1] * x) % mod;
}
}
ll x = 0, y = 0;
for (int i = 0; i <= cnt; i++) {
cout << val[i] << ' ';
x = (x + val[i] * i) % mod;
y = (y + val[i] * (cnt - i)) % mod;
}
return {x, y};
}
int count_ways(int l, int r) {
for (int i = l; i <= r; i++) {
a[i] = 1 - a[i];
}
return get(0).f;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
13912 KB |
Possible tampering with the output or unexpected termination of the program |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
13912 KB |
Possible tampering with the output or unexpected termination of the program |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
13912 KB |
Possible tampering with the output or unexpected termination of the program |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
18 ms |
15960 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
18 ms |
15960 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
13912 KB |
Possible tampering with the output or unexpected termination of the program |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
13912 KB |
Possible tampering with the output or unexpected termination of the program |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
13912 KB |
Possible tampering with the output or unexpected termination of the program |
2 |
Halted |
0 ms |
0 KB |
- |