// failed/solution-prabowo-perfect-binary-linear-update.cpp
// O(N + M + Q log M)
#include "circuit.h"
#include <algorithm>
#include <vector>
const int kMod = 1000002022;
std::vector<int> dp0, dp1;
void compute(int u) {
int l = u * 2 + 1, r = u * 2 + 2;
int diff = (1LL * dp0[l] * dp1[r] + 1LL * dp1[l] * dp0[r]) % kMod;
dp0[u] = (2LL * dp0[l] * dp0[r] + diff) % kMod;
dp1[u] = (2LL * dp1[l] * dp1[r] + diff) % kMod;
}
void init(int N, int M, std::vector<int>, std::vector<int> A) {
dp0.resize(N + M);
dp1.resize(N + M);
for (int i = N; i < N + M; ++i) {
if (A[i - N]) {
dp1[i] = 1;
} else {
dp0[i] = 1;
}
}
for (int i = N - 1; i >= 0; --i) {
compute(i);
}
}
int count_ways(int L, int R) {
for (int i = L; i <= R; ++i) {
std::swap(dp0[i], dp1[i]);
for (int u = (i - 1) / 2; u > 0; u = (u - 1) / 2) {
compute(u);
}
compute(0);
}
return dp1[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
252 KB |
Output is correct |
2 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '706880838', found: '573051996' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
252 KB |
Output is correct |
2 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
681 ms |
1488 KB |
Output is correct |
2 |
Correct |
888 ms |
2852 KB |
Output is correct |
3 |
Correct |
963 ms |
2832 KB |
Output is correct |
4 |
Correct |
1236 ms |
2832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
681 ms |
1488 KB |
Output is correct |
2 |
Correct |
888 ms |
2852 KB |
Output is correct |
3 |
Correct |
963 ms |
2832 KB |
Output is correct |
4 |
Correct |
1236 ms |
2832 KB |
Output is correct |
5 |
Execution timed out |
3055 ms |
1572 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Incorrect |
1 ms |
208 KB |
1st lines differ - on the 1st token, expected: '706880838', found: '573051996' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
252 KB |
Output is correct |
2 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
252 KB |
Output is correct |
2 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |