General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
120346640 Practice:
memoryallocator
1066E - 14 Rust Wrong answer on test 3 31 ms 544 KB 2021-06-23 10:36:36 2021-06-23 10:36:36
→ Source
use std::*;
use io::{stdin, Read};

const MOD: u128 = 998_244_353;

fn add(x: u64, y: u64) -> u64 {
    (x as u128 + y as u128).rem_euclid(MOD) as 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: u64 = 1;
    let mut res: u64 = 0;
    let mut ans: u64 = 0;
    for (i, b) in b.into_iter().enumerate() {
        if let Some(b'1') = a.get(i) {
            res = add(res, pw);
        }
        if b == b'1' {
            ans = add(ans, res);
        }
        pw = add(pw, pw);
    }
    println!("{}", ans)
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details