This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef LOCAL
#include "grader.h"
#else
#include "circuit.h"
#endif
#include <vector>
using ll = long long;
const int NMAX = 2e5;
const int mod = 1e9 + 2022;
int depth[NMAX];
int p2[NMAX];
std::vector<int> a;
int n, m;
void init(int N, int M, std::vector<int> parent, std::vector<int> A) {
n = N;
m = M;
a = A;
p2[0] = 1;
for (int i = 1; i <= n + m; i++) {
p2[i] = p2[i - 1] * 2 % mod;
}
for (int i = 1; i < n + m; i++) {
depth[i] = 1 + depth[parent[i]];
}
}
int count_ways(int L, int R) {
L -= n, R -= n;
for (int i = L; i <= R; i++) {
a[i] ^= 1;
}
ll answer = 0;
for (int i = 0; i < m; i++) {
if (a[i]) {
answer += p2[depth[i + n]];
}
}
return answer % mod;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |