/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| 1.15M| auto operator+(node t) -> node {
13| 1.15M| return {u32(u64(t.a) * a % P), u32((u64(t.a) * b + t.b) % P)};
14| 1.15M| }
15| 839k| 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| 277k| for (int i = 0; i < n; ++i) {
^277k
------------------
| Branch (25:19): [True: 100.00%, False: 0.00%]
------------------
26| 277k| int k = i * 2 + 1;
27| 277k| a[k] = {rd.uw(), rd.uw()};
28| 554k| for (int j = 1; k & (j * 2); k -= j, j *= 2) {
^277k
------------------
| Branch (28:21): [True: 50.00%, False: 50.00%]
------------------
29| 277k| a[k - j] = a[k - j * 2] + a[k];
30| 277k| }
31| 277k| }
32| 99.1k| while (q--) {
------------------
| Branch (32:10): [True: 100.00%, False: 0.00%]
------------------
33| 99.1k| let t = rd.u1();
34| 99.1k| if (t == 0) {
------------------
| Branch (34:9): [True: 50.09%, False: 49.91%]
------------------
35| 49.6k| int k = rd.uh() * 2 + 1;
36| 49.6k| a[k] = {rd.uw(), rd.uw()};
37| 927k| for (int j = 1;; j *= 2) {
^878k
38| 927k| if (k & (j * 2)) {
------------------
| Branch (38:13): [True: 47.32%, False: 52.68%]
------------------
39| 439k| a[k - j] = a[k - j * 2] + a[k];
40| 439k| k -= j;
41| 488k| } else {
42| 488k| if (k + j * 3 > n * 2) break;
^49.6k
------------------
| Branch (42:15): [True: 10.16%, False: 89.84%]
------------------
43| 439k| a[k + j] = a[k] + a[k + j * 2];
44| 439k| k += j;
45| 439k| }
46| 927k| }
47| 49.6k| }
48| 99.1k| if (t == 1) {
------------------
| Branch (48:9): [True: 49.91%, False: 50.09%]
------------------
49| 49.4k| int l = rd.uh() * 2 + 1;
50| 49.4k| int r = rd.uh() * 2 + 1;
51| 49.4k| u32 x = a[l] + rd.uw();
52| 49.4k| int k = (-1 << log(l ^ r)) & r;
53| 449k| for (++l; l < k; l += l & -l) {
^400k
------------------
| Branch (53:17): [True: 89.00%, False: 11.00%]
------------------
54| 400k| x = a[l + (l & -l) / 2] + x;
55| 400k| }
56| 439k| for (--r; k < r;) {
------------------
| Branch (56:17): [True: 88.74%, False: 11.26%]
------------------
57| 390k| int t = 1 << log(r - k);
58| 390k| x = a[k + t / 2] + x;
59| 390k| k += t;
60| 390k| }
61| 49.4k| wt.uw(x);
62| 49.4k| }
63| 99.1k| }
64| 1| return 0;
65| 1|}