/tmp/solutions/build/point_set_range_composite-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| 3.89M| auto operator+(node t) -> node {
13| 3.89M| return {u32(u64(t.a) * a % P), u32((u64(t.a) * b + t.b) % P)};
14| 3.89M| }
15| 3.59M| auto operator+(u32 x) -> u32 { return (u64(a) * x + b) % P; }
16| |} a[N];
17| |
18| |} // namespace
19| |
20| 1|int main() {
21| 1| rd rd;
22| 1| wt wt;
23| 1| int n = rd.uh();
24| 1| int q = rd.uh();
25| 389k| for (int i = 0; i < n; ++i) {
^389k
------------------
| Branch (25:19): [True: 100.00%, False: 0.00%]
------------------
26| 389k| int k = i * 2 + 1;
27| 389k| a[k] = {rd.uw(), rd.uw()};
28| 779k| for (int j = 1; k & (j * 2); k -= j, j *= 2) {
^389k
------------------
| Branch (28:21): [True: 50.00%, False: 50.00%]
------------------
29| 389k| a[k - j] = a[k - j * 2] + a[k];
30| 389k| }
31| 389k| }
32| 410k| while (q--) {
------------------
| Branch (32:10): [True: 100.00%, False: 0.00%]
------------------
33| 410k| let t = rd.u1();
34| 410k| if (t == 0) {
------------------
| Branch (34:9): [True: 50.01%, False: 49.99%]
------------------
35| 205k| int k = rd.uh() * 2 + 1;
36| 205k| a[k] = {rd.uw(), rd.uw()};
37| 3.71M| for (int j = 1;; j *= 2) {
^3.50M
38| 3.71M| if (k & (j * 2)) {
------------------
| Branch (38:13): [True: 47.27%, False: 52.73%]
------------------
39| 1.75M| a[k - j] = a[k - j * 2] + a[k];
40| 1.75M| k -= j;
41| 1.95M| } else {
42| 1.95M| if (k + j * 3 > n * 2) break;
^205k
------------------
| Branch (42:15): [True: 10.50%, False: 89.50%]
------------------
43| 1.75M| a[k + j] = a[k] + a[k + j * 2];
44| 1.75M| k += j;
45| 1.75M| }
46| 3.71M| }
47| 205k| }
48| 410k| if (t == 1) {
------------------
| Branch (48:9): [True: 49.99%, False: 50.01%]
------------------
49| 205k| int l = rd.uh() * 2 + 1;
50| 205k| int r = rd.uh() * 2 + 1;
51| 205k| u32 x = a[l] + rd.uw();
52| 205k| int k = (-1 << log(l ^ r)) & r;
53| 1.92M| for (++l; l < k; l += l & -l) {
^1.72M
------------------
| Branch (53:17): [True: 89.34%, False: 10.66%]
------------------
54| 1.72M| x = a[l + (l & -l) / 2] + x;
55| 1.72M| }
56| 1.87M| for (--r; k < r;) {
------------------
| Branch (56:17): [True: 89.04%, False: 10.96%]
------------------
57| 1.66M| int t = 1 << log(r - k);
58| 1.66M| x = a[k + t / 2] + x;
59| 1.66M| k += t;
60| 1.66M| }
61| 205k| wt.uw(x);
62| 205k| }
63| 410k| }
64| 1| return 0;
65| 1|}