?
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | |
---|---|---|---|---|---|---|---|---|---|
120343900 |
Practice: memoryallocator |
1066E - 14 | Rust | Wrong answer on test 3 | 31 ms | 556 KB | 2021-06-23 09:56:42 | 2021-06-23 09:56:42 |
use std::*; use io::{stdin, Read}; const MOD: UType = 998244353; type UType = u64; fn main() { let mut n_and_m = String::new(); stdin().read_line(&mut n_and_m); let mut n_and_m: Vec<&str> = n_and_m.trim().split(" ").collect(); let m = n_and_m.pop().unwrap().parse::<usize>().unwrap(); let n = n_and_m.pop().unwrap().parse::<usize>().unwrap(); drop(n_and_m); let mut a = vec![b'\0'; n]; stdin().read(&mut a); stdin().read_line(&mut String::new()); a.reverse(); let mut b = vec![b'\0'; m]; stdin().read(&mut b); b.reverse(); let mut pw: UType = 1; let mut res: UType = 0; let mut ans: UType = 0; for (i, b) in b.into_iter().enumerate() { if let Some(b'1') = a.get(i) { res = (res + pw).rem_euclid(MOD); } if b == b'1' { ans = (ans + res).rem_euclid(MOD); } pw = (pw + pw).rem_euclid(MOD); } println!("{}", ans) }
?
?
?
?