Problems Submissions
Register Login 質問(Gitter) GitHub

Submit Info #3635

Problem Lang User Status Time Memory
Point Add Range Sum rust ziita1111 WA 109 ms 9.37 MiB

ケース詳細
Name Status Time Memory
example_00 AC 6 ms 0.69 MiB
max_random_00 WA 34 ms 9.36 MiB
max_random_01 WA 34 ms 9.37 MiB
max_random_02 WA 84 ms 9.28 MiB
max_random_03 WA 109 ms 9.36 MiB
max_random_04 WA 50 ms 9.28 MiB
random_00 WA 39 ms 7.41 MiB
random_01 WA 28 ms 8.71 MiB
random_02 WA 10 ms 1.64 MiB
random_03 WA 58 ms 8.08 MiB
random_04 WA 22 ms 5.55 MiB
small_00 WA 7 ms 0.70 MiB
small_01 WA 6 ms 0.66 MiB
small_02 WA 7 ms 0.63 MiB
small_03 WA 6 ms 0.66 MiB
small_04 WA 5 ms 0.62 MiB
small_05 WA 7 ms 0.67 MiB
small_06 WA 6 ms 0.59 MiB
small_07 WA 6 ms 0.63 MiB
small_08 WA 8 ms 0.60 MiB
small_09 WA 7 ms 0.62 MiB

#![allow(unused_imports)] #![allow(non_snake_case, unused)] use std::cmp::*; use std::collections::*; use std::ops::*; macro_rules! eprint { ($($t:tt)*) => {{ use ::std::io::Write; let _ = write!(::std::io::stderr(), $($t)*); }}; } macro_rules! eprintln { () => { eprintln!(""); }; ($($t:tt)*) => {{ use ::std::io::Write; let _ = writeln!(::std::io::stderr(), $($t)*); }}; } macro_rules! dbg { ($v:expr) => {{ let val = $v; eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val); val }} } macro_rules! mat { ($($e:expr),*) => { Vec::from(vec![$($e),*]) }; ($($e:expr,)*) => { Vec::from(vec![$($e),*]) }; ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) }; ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) }; } macro_rules! ok { ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => { $a$([$i])*.$f($($t),*) }; ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { { let t = $e; ok!($a$([$i])*.$f($($es),*)$(@$t)*@t) } }; } pub fn readln() -> String { let mut line = String::new(); ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e)); line } macro_rules! read { ($($t:tt),*; $n:expr) => {{ let stdin = ::std::io::stdin(); let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| { let line = line.unwrap(); let mut it = line.split_whitespace(); _read!(it; $($t),*) }).collect::<Vec<_>>(); ret }}; ($($t:tt),*) => {{ let line = readln(); let mut it = line.split_whitespace(); _read!(it; $($t),*) }}; } macro_rules! _read { ($it:ident; [char]) => { _read!($it; String).chars().collect::<Vec<_>>() }; ($it:ident; [u8]) => { Vec::from(_read!($it; String).into_bytes()) }; ($it:ident; usize1) => { $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1 }; ($it:ident; [usize1]) => { $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>() }; ($it:ident; [$t:ty]) => { $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>() }; ($it:ident; $t:ty) => { $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e)) }; ($it:ident; $($t:tt),+) => { ($(_read!($it; $t)),*) }; } pub fn main() { let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join(); } // const MOD: u32 = 1_000_000_007; const MOD: i64 = 998_244_353; const INF: i64 = std::i64::MAX; pub trait SetMinMax { fn setmin(&mut self, v: Self) -> bool; fn setmax(&mut self, v: Self) -> bool; } impl<T> SetMinMax for T where T: PartialOrd { fn setmin(&mut self, v: T) -> bool { *self > v && { *self = v; true } } fn setmax(&mut self, v: T) -> bool { *self < v && { *self = v; true } } } // 平方分割 pub struct SquareDecomp{ v: Vec<i64>, n: usize, b: usize, squares: Vec<i64>, } impl SquareDecomp{ pub fn new(v: Vec<i64>) -> Self { let n = v.len(); let b = (n as f64).sqrt() as usize; SquareDecomp{ v: v, n: n, b: b, squares: vec![0;n/b] } } pub fn init(&mut self) { for i in 0..self.n/self.b { let mut sum = 0; for j in 0..self.b { let idx = i*self.b + j; if idx>=self.n {break;} sum += self.v[idx]; sum %= MOD; } self.squares[i] = sum; } } pub fn query(&self, s: usize, t: usize) -> i64 { let mut idx = s; let mut ans = 0; loop { if idx>=t {break;} if idx%self.b==0 && (idx+self.b-1)<t { ans += self.squares[idx/self.b]; ans %= MOD; idx += self.b; continue; } for i in 0..self.b { if idx>=t {break;} ans += self.v[idx]; ans %= MOD; idx += 1; if idx%self.b==0 {break;} } } ans } pub fn update(&mut self, p: usize, x: i64){ self.v[p] += x; self.squares[p/self.b] += x; } } fn solve() { let (n,q) = read!(usize, usize); let a = read!([i64]); let mut sq = SquareDecomp::new(a); sq.init(); for i in 0..q { let (x,y,z) = read!(usize,usize,i64); if x==0 { sq.update(y,z); } else{ let ret = sq.query(y,z as usize); println!("{}", ret); } } } fn run() { solve(); }