// O(N^2)
#include <bits/stdc++.h>
#include "circuit.h"
#include "Debug.h"
using namespace std;
const int BASE = 1e9 + 2022;
const int N = 100100;
int n, m;
vector<int> a[N];
vector<int> states;
vector<vector<long long>> f;
void init(int N, int M, vector<int> P, vector<int> A)
{
n = N;
m = M;
for (int i = 1; i < n + m; i++)
a[P[i]].push_back(i);
states = A;
f = vector<vector<long long>>(n + m, vector<long long>(2));
}
void calc(int x)
{
if (x >= n)
{
f[x] = {states[x - n] ^ 1, states[x - n]};
return;
}
vector<long long> ways(size(a[x]) + 1);
ways[0] = 1;
int curSz = 0;
for (int y : a[x])
{
calc(y);
for (int i = curSz; i >= 0; i--)
{
ways[i + 1] += ways[i] * f[y][1];
ways[i + 1] %= BASE;
ways[i] *= f[y][0];
ways[i] %= BASE;
}
curSz++;
}
f[x][0] = f[x][1] = 0;
for (int i = 1; i <= curSz; i++)
ways[i] = (ways[i] + ways[i - 1]) % BASE;
for (int i = 1; i <= curSz; i++)
{
f[x][1] += ways[curSz] - ways[i - 1] + BASE;
f[x][1] %= BASE;
f[x][0] += ways[i - 1];
f[x][0] %= BASE;
}
}
int count_ways(int L, int R)
{
for (int i = L; i <= R; i++)
states[i - n] ^= 1;
calc(0);
return int(f[0][1]);
}
Compilation message
circuit.cpp:4:10: fatal error: Debug.h: No such file or directory
4 | #include "Debug.h"
| ^~~~~~~~~
compilation terminated.