/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| 968| auto operator+(node t) -> node {
13| 968| return {u32(u64(t.a) * a % P), u32((u64(t.a) * b + t.b) % P)};
14| 968| }
15| 1.31k| 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| 6| for (int i = 0; i < n; ++i) {
^5
------------------
| Branch (25:19): [True: 83.33%, False: 16.67%]
------------------
26| 5| int k = i * 2 + 1;
27| 5| a[k] = {rd.uw(), rd.uw()};
28| 8| for (int j = 1; k & (j * 2); k -= j, j *= 2) {
^3
------------------
| Branch (28:21): [True: 37.50%, False: 62.50%]
------------------
29| 3| a[k - j] = a[k - j * 2] + a[k];
30| 3| }
31| 5| }
32| 1.00k| while (q--) {
------------------
| Branch (32:10): [True: 99.90%, False: 0.10%]
------------------
33| 1.00k| let t = rd.u1();
34| 1.00k| if (t == 0) {
------------------
| Branch (34:9): [True: 50.40%, False: 49.60%]
------------------
35| 504| int k = rd.uh() * 2 + 1;
36| 504| a[k] = {rd.uw(), rd.uw()};
37| 1.30k| for (int j = 1;; j *= 2) {
^796
38| 1.30k| if (k & (j * 2)) {
------------------
| Branch (38:13): [True: 30.46%, False: 69.54%]
------------------
39| 396| a[k - j] = a[k - j * 2] + a[k];
40| 396| k -= j;
41| 904| } else {
42| 904| if (k + j * 3 > n * 2) break;
^504
------------------
| Branch (42:15): [True: 55.75%, False: 44.25%]
------------------
43| 400| a[k + j] = a[k] + a[k + j * 2];
44| 400| k += j;
45| 400| }
46| 1.30k| }
47| 504| }
48| 1.00k| if (t == 1) {
------------------
| Branch (48:9): [True: 49.60%, False: 50.40%]
------------------
49| 496| int l = rd.uh() * 2 + 1;
50| 496| int r = rd.uh() * 2 + 1;
51| 496| u32 x = a[l] + rd.uw();
52| 496| node f = {1, 0};
53| 496| int k = (-1 << log(l ^ r)) & r;
54| 821| for (++l; l < k; l += l & -l) {
^325
------------------
| Branch (54:17): [True: 39.59%, False: 60.41%]
------------------
55| 325| x = a[l + (l & -l) / 2] + x;
56| 325| }
57| 665| for (--r; r > k; r -= r & -r) {
^169
------------------
| Branch (57:17): [True: 25.41%, False: 74.59%]
------------------
58| 169| f = a[r - (r & -r) / 2] + f;
59| 169| }
60| 496| x = f + x;
61| 496| wt.uw(x);
62| 496| }
63| 1.00k| }
64| 1| return 0;
65| 1|}