#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Max = 2e5 + 1;
const int Mod = 1e9 + 2022;
ll n, m, dp[Max][2];
void update(int node, int left, int right, int idx) {
if (left == idx && right == idx) {
swap(dp[node][0], dp[node][1]);
return;
}
int mid = (left + right) / 2;
int l = node * 2 + 1;
int r = node * 2 + 2;
if (idx <= mid) {
update(l, left, mid, idx);
}
else {
update(r, mid + 1, right, idx);
}
dp[node][0] = dp[l][1] * dp[r][0] + dp[l][0] * dp[r][1] + 2 * dp[l][0] * dp[r][0];
dp[node][1] = dp[l][1] * dp[r][0] + dp[l][0] * dp[r][1] + 2 * dp[l][1] * dp[r][1];
dp[node][0] %= Mod;
dp[node][1] %= Mod;
}
void build(int node, int left, int right, vector<int>& a) {
if (left == right) {
dp[node][A[left]] = 1;
return;
}
int mid = (left + right) / 2;
int l = node * 2 + 1;
int r = node * 2 + 2;
build(l, left, mid, a);
build(r, mid + 1, right, a);
dp[node][0] = dp[l][1] * dp[r][0] + dp[l][0] * dp[r][1] + 2 * dp[l][0] * dp[r][0];
dp[node][1] = dp[l][1] * dp[r][0] + dp[l][0] * dp[r][1] + 2 * dp[l][1] * dp[r][1];
dp[node][0] %= Mod;
dp[node][1] %= Mod;
}
void init(int N, int M, vector<int> P, vector<int> A) {
n = N, m = M;
build(0, 0, M - 1, A);
}
int count_ways(int L, int R) {
update(0, 0, m - 1, L - n);
return dp[0][1];
}
Compilation message
circuit.cpp: In function 'void build(int, int, int, std::vector<int>&)':
circuit.cpp:38:18: error: 'A' was not declared in this scope
38 | dp[node][A[left]] = 1;
| ^