@@ -15,6 +15,7 @@ int main() {
1515 return {int (1LL * l[0 ] * r[0 ] % mod),
1616 int ((1LL * r[0 ] * l[1 ] + r[1 ]) % mod)};
1717 });
18+ const array<int , 2 > unit = {1 , 0 };
1819 while (q--) {
1920 int type;
2021 cin >> type;
@@ -25,8 +26,49 @@ int main() {
2526 } else {
2627 int l, r, x;
2728 cin >> l >> r >> x;
28- auto [slope, y_int] = st.query (l, r - 1 );
29- cout << (1LL * slope * x + y_int) % mod << ' \n ' ;
29+ r--;
30+ array<int , 2 > res = st.query (l, r);
31+ {
32+ array<int , 2 > walk_res = {1 , 0 };
33+ int idx = st.max_right (l, r,
34+ [&](const array<int , 2 >& curr_line) -> bool {
35+ walk_res = curr_line;
36+ return 1 ;
37+ });
38+ assert (res == walk_res);
39+ assert (idx == r + 1 );
40+ }
41+ {
42+ array<int , 2 > walk_res = unit;
43+ int idx = st.max_right (l, r,
44+ [&](const array<int , 2 >& curr_line) -> bool {
45+ walk_res = curr_line;
46+ return 0 ;
47+ });
48+ assert (walk_res == st.query (l, l));
49+ assert (idx == l);
50+ }
51+ {
52+ array<int , 2 > walk_res = unit;
53+ int idx = st.min_left (l, r,
54+ [&](const array<int , 2 >& curr_line) -> bool {
55+ walk_res = curr_line;
56+ return 1 ;
57+ });
58+ assert (walk_res == res);
59+ assert (idx == l - 1 );
60+ }
61+ {
62+ array<int , 2 > walk_res = unit;
63+ int idx = st.min_left (l, r,
64+ [&](const array<int , 2 >& curr_line) -> bool {
65+ walk_res = curr_line;
66+ return 0 ;
67+ });
68+ assert (walk_res == st.query (r, r));
69+ assert (idx == r);
70+ }
71+ cout << (1LL * res[0 ] * x + res[1 ]) % mod << ' \n ' ;
3072 }
3173 }
3274 return 0 ;
0 commit comments