library_checker/datastructure/
point_set_range_composite.rs1use competitive::prelude::*;
2#[doc(no_inline)]
3pub use competitive::{
4 algebra::LinearOperation,
5 data_structure::SegmentTree,
6 num::{MInt, mint_basic::MInt998244353},
7};
8
9#[verify::library_checker("point_set_range_composite")]
10pub fn point_set_range_composite(reader: impl Read, mut writer: impl Write) {
11 let s = read_all_unchecked(reader);
12 let mut scanner = Scanner::new(&s);
13 scan!(scanner, n, q, ab: [(MInt998244353, MInt998244353); n]);
14 let mut seg = SegmentTree::<LinearOperation<_>>::from_vec(ab);
15 for _ in 0..q {
16 match scanner.scan::<usize>() {
17 0 => {
18 scan!(scanner, p, cd: (MInt998244353, MInt998244353));
19 seg.set(p, cd);
20 }
21 1 => {
22 scan!(scanner, l, r, x: MInt998244353);
23 let (a, b) = seg.fold(l..r);
24 writeln!(writer, "{}", a * x + b).ok();
25 }
26 _ => panic!("unknown query"),
27 }
28 }
29}