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;
void init(int N, int m, std::vector<int> parent, std::vector<int> A) {
n = N;
a = A;
p2[0] = 1;
for (int i = 1; i < n + m; i++) {
depth[i] = 1 + depth[parent[i]];
p2[i] = p2[i - 1] * 2 % mod;
}
}
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 = L; i <= R; i++) {
if (a[i]) {
answer += p2[depth[i]];
}
}
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... |