/tmp/solutions/build/point_set_range_composite-slow.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| 6.88M| auto operator+(node t) -> node {
13| 6.88M| return {u32(u64(t.a) * a % P), u32((u64(t.a) * b + t.b) % P)};
14| 6.88M| }
15| 2.62M| 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| 500k| for (int i = 0; i < n; ++i) {
^500k
------------------
| Branch (25:19): [True: 100.00%, False: 0.00%]
------------------
26| 500k| int k = i * 2 + 1;
27| 500k| a[k] = {rd.uw(), rd.uw()};
28| 999k| for (int j = 1; k & (j * 2); k -= j, j *= 2) {
^499k
------------------
| Branch (28:21): [True: 50.00%, False: 50.00%]
------------------
29| 499k| a[k - j] = a[k - j * 2] + a[k];
30| 499k| }
31| 500k| }
32| 500k| while (q--) {
------------------
| Branch (32:10): [True: 100.00%, False: 0.00%]
------------------
33| 500k| let t = rd.u1();
34| 500k| if (t == 0) {
------------------
| Branch (34:9): [True: 49.91%, False: 50.09%]
------------------
35| 249k| int k = rd.uh() * 2 + 1;
36| 249k| a[k] = {rd.uw(), rd.uw()};
37| 4.53M| for (int j = 1;; j *= 2) {
^4.29M
38| 4.53M| if (k & (j * 2)) {
------------------
| Branch (38:13): [True: 47.25%, False: 52.75%]
------------------
39| 2.14M| a[k - j] = a[k - j * 2] + a[k];
40| 2.14M| k -= j;
41| 2.39M| } else {
42| 2.39M| if (k + j * 3 > n * 2) break;
^249k
------------------
| Branch (42:15): [True: 10.42%, False: 89.58%]
------------------
43| 2.14M| a[k + j] = a[k] + a[k + j * 2];
44| 2.14M| k += j;
45| 2.14M| }
46| 4.53M| }
47| 249k| }
48| 500k| if (t == 1) {
------------------
| Branch (48:9): [True: 50.09%, False: 49.91%]
------------------
49| 250k| int l = rd.uh() * 2 + 1;
50| 250k| int r = rd.uh() * 2 + 1;
51| 250k| u32 x = a[l] + rd.uw();
52| 250k| node f = {1, 0};
53| 250k| int k = (-1 << log(l ^ r)) & r;
54| 2.37M| for (++l; l < k; l += l & -l) {
^2.12M
------------------
| Branch (54:17): [True: 89.46%, False: 10.54%]
------------------
55| 2.12M| x = a[l + (l & -l) / 2] + x;
56| 2.12M| }
57| 2.34M| for (--r; r > k; r -= r & -r) {
^2.09M
------------------
| Branch (57:17): [True: 89.31%, False: 10.69%]
------------------
58| 2.09M| f = a[r - (r & -r) / 2] + f;
59| 2.09M| }
60| 250k| x = f + x;
61| 250k| wt.uw(x);
62| 250k| }
63| 500k| }
64| 1| return 0;
65| 1|}