/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| 2.81M| auto operator+(node t) -> node {
13| 2.81M| return {u32(u64(t.a) * a % P), u32((u64(t.a) * b + t.b) % P)};
14| 2.81M| }
15| 2.78M| 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| 53.3k| for (int i = 0; i < n; ++i) {
^53.3k
------------------
| Branch (25:19): [True: 100.00%, False: 0.00%]
------------------
26| 53.3k| int k = i * 2 + 1;
27| 53.3k| a[k] = {rd.uw(), rd.uw()};
28| 106k| for (int j = 1; k & (j * 2); k -= j, j *= 2) {
^53.3k
------------------
| Branch (28:21): [True: 50.00%, False: 50.00%]
------------------
29| 53.3k| a[k - j] = a[k - j * 2] + a[k];
30| 53.3k| }
31| 53.3k| }
32| 382k| while (q--) {
------------------
| Branch (32:10): [True: 100.00%, False: 0.00%]
------------------
33| 382k| let t = rd.u1();
34| 382k| if (t == 0) {
------------------
| Branch (34:9): [True: 50.07%, False: 49.93%]
------------------
35| 191k| int k = rd.uh() * 2 + 1;
36| 191k| a[k] = {rd.uw(), rd.uw()};
37| 2.95M| for (int j = 1;; j *= 2) {
^2.76M
38| 2.95M| if (k & (j * 2)) {
------------------
| Branch (38:13): [True: 46.77%, False: 53.23%]
------------------
39| 1.38M| a[k - j] = a[k - j * 2] + a[k];
40| 1.38M| k -= j;
41| 1.57M| } else {
42| 1.57M| if (k + j * 3 > n * 2) break;
^191k
------------------
| Branch (42:15): [True: 12.16%, False: 87.84%]
------------------
43| 1.38M| a[k + j] = a[k] + a[k + j * 2];
44| 1.38M| k += j;
45| 1.38M| }
46| 2.95M| }
47| 191k| }
48| 382k| if (t == 1) {
------------------
| Branch (48:9): [True: 49.93%, False: 50.07%]
------------------
49| 190k| int l = rd.uh() * 2 + 1;
50| 190k| int r = rd.uh() * 2 + 1;
51| 190k| u32 x = a[l] + rd.uw();
52| 190k| int k = (-1 << log(l ^ r)) & r;
53| 1.51M| for (++l; l < k; l += l & -l) {
^1.32M
------------------
| Branch (53:17): [True: 87.41%, False: 12.59%]
------------------
54| 1.32M| x = a[l + (l & -l) / 2] + x;
55| 1.32M| }
56| 1.46M| for (--r; k < r;) {
------------------
| Branch (56:17): [True: 86.93%, False: 13.07%]
------------------
57| 1.26M| int t = 1 << log(r - k);
58| 1.26M| x = a[k + t / 2] + x;
59| 1.26M| k += t;
60| 1.26M| }
61| 190k| wt.uw(x);
62| 190k| }
63| 382k| }
64| 1| return 0;
65| 1|}