/tmp/solutions/build/range_affine_point_get-main.cpp:
1| |#include <common.h>
2| |#include <toy/bit.h>
3| |prelude;
4| |
5| |namespace {
6| |
7| |constexpr int N = 1e6;
8| |constexpr int P = 998244353;
9| |
10| |struct node {
11| | u32 a, b;
12| 121M| auto operator+(node t) -> node {
13| 121M| return {u32(u64(t.a) * a % P), u32((u64(t.a) * b + t.b) % P)};
14| 121M| }
15| 24.9M| auto operator+(u32 x) -> u32 { return (u64(a) * x + b) % P; }
16| 121M| auto operator+=(node t) -> void { *this = *this + t; }
17| |} a[N];
18| |
19| 2.71M|void pushdown(int k) {
20| 52.6M| for (int i = log(k) - 1; i >= 0; --i) {
^49.9M
------------------
| Branch (20:28): [True: 94.84%, False: 5.16%]
------------------
21| 49.9M| node t = a[k >> i >> 1];
22| 49.9M| a[k >> i >> 1] = node{1, 0};
23| 49.9M| a[k >> i ^ 0] += t;
24| 49.9M| a[k >> i ^ 1] += t;
25| 49.9M| }
26| 2.71M|}
27| |
28| |} // namespace
29| |
30| 19|int main() {
31| 19| rd rd;
32| 19| wt wt;
33| 19| int n = rd.uh();
34| 19| int q = rd.uh();
35| 2.40M| for (int i = 0; i < n; ++i) a[i] = {1, 0}, a[n + i].b = rd.uw();
^2.40M^2.40M
------------------
| Branch (35:19): [True: 100.00%, False: 0.00%]
------------------
36| 2.71M| while (q--) {
------------------
| Branch (36:10): [True: 100.00%, False: 0.00%]
------------------
37| 2.71M| let t = rd.u1();
38| 2.71M| if (t == 0) {
------------------
| Branch (38:9): [True: 50.01%, False: 49.99%]
------------------
39| 1.35M| int l = n + rd.uh();
40| 1.35M| int r = n + rd.uh() - 1;
41| 1.35M| node x = {rd.uw(), rd.uw()};
42| 1.35M| pushdown(l--);
43| 1.35M| pushdown(r++);
44| 1.35M| int k = log(l ^ r);
45| 12.2M| for (int t = ~l & ~(-1 << k), i; t > 0; t -= 1 << i) {
^10.9M
------------------
| Branch (45:40): [True: 88.93%, False: 11.07%]
------------------
46| 10.9M| i = log(t);
47| 10.9M| a[l >> i ^ 1] += x;
48| 10.9M| }
49| 12.3M| for (int t = +r & ~(-1 << k), i; t > 0; t -= 1 << i) {
^11.0M
------------------
| Branch (49:40): [True: 89.01%, False: 10.99%]
------------------
50| 11.0M| i = log(t);
51| 11.0M| a[r >> i ^ 1] += x;
52| 11.0M| }
53| 1.35M| }
54| 2.71M| if (t == 1) {
------------------
| Branch (54:9): [True: 49.99%, False: 50.01%]
------------------
55| 1.35M| int k = n + rd.uh();
56| 1.35M| u32 x = a[k].b;
57| 26.3M| for (k /= 2; k > 0; k /= 2) x = a[k] + x;
^24.9M ^24.9M
------------------
| Branch (57:20): [True: 94.84%, False: 5.16%]
------------------
58| 1.35M| wt.uw(x);
59| 1.35M| }
60| 2.71M| }
61| 19| return 0;
62| 19|}