結果

問題 No.1870 Xor Matrix
ユーザー phsplsphspls
提出日時 2023-01-11 00:05:42
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,037 bytes
コンパイル時間 19,607 ms
コンパイル使用メモリ 381,600 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-21 12:54:00
合計ジャッジ時間 16,988 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

const MOD: usize = 998244353;

fn power(base: usize, times: usize) -> usize {
    if times == 0 { return 1usize; }
    if times == 1 { return base; }
    let temp = power(base, times/2);
    temp * temp % MOD * power(base, times%2) % MOD
}

fn main() {
    let mut nm = String::new();
    std::io::stdin().read_line(&mut nm).ok();
    let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nm[0];
    let m = nm[1];
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).ok();
    let b: Vec<usize> = b.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let left = a.into_iter().fold(0usize, |x, y| x ^ y);
    let right = b.into_iter().fold(0usize, |x, y| x ^ y);
    if left ^ right > 0 {
        println!("0");
    } else {
        println!("{}", power(2usize, 20*(n-1)*(m-1)));
    }
}
0