結果

問題 No.1958 Bit Game
ユーザー phsplsphspls
提出日時 2022-09-28 11:17:42
言語 Rust
(1.77.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 1,433 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 150,128 KB
実行使用メモリ 9,400 KB
最終ジャッジ日時 2023-08-24 04:21:00
合計ジャッジ時間 3,710 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
9,328 KB
testcase_01 AC 49 ms
9,400 KB
testcase_02 AC 50 ms
9,292 KB
testcase_03 AC 49 ms
9,324 KB
testcase_04 AC 49 ms
9,356 KB
testcase_05 AC 49 ms
9,372 KB
testcase_06 AC 49 ms
9,364 KB
testcase_07 AC 49 ms
9,332 KB
testcase_08 AC 49 ms
9,376 KB
testcase_09 AC 49 ms
9,380 KB
testcase_10 AC 13 ms
4,376 KB
testcase_11 AC 24 ms
5,460 KB
testcase_12 AC 27 ms
6,576 KB
testcase_13 AC 30 ms
5,840 KB
testcase_14 AC 26 ms
5,400 KB
testcase_15 AC 25 ms
7,476 KB
testcase_16 AC 17 ms
5,576 KB
testcase_17 AC 40 ms
8,184 KB
testcase_18 AC 37 ms
8,084 KB
testcase_19 AC 22 ms
6,172 KB
testcase_20 AC 32 ms
5,268 KB
testcase_21 AC 28 ms
7,732 KB
testcase_22 AC 17 ms
4,376 KB
testcase_23 AC 15 ms
4,780 KB
testcase_24 AC 39 ms
7,152 KB
testcase_25 AC 18 ms
5,004 KB
testcase_26 AC 30 ms
5,480 KB
testcase_27 AC 23 ms
7,068 KB
testcase_28 AC 35 ms
6,260 KB
testcase_29 AC 19 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `BITS` should have a snake case name
  --> Main.rs:18:9
   |
18 |     let BITS = 18;
   |         ^^^^ help: convert the identifier to snake case: `bits`
   |
   = note: `#[warn(non_snake_case)]` on by default

warning: 1 warning emitted

ソースコード

diff #

const MOD: usize = 998244353;

fn main() {
    let mut nxy = String::new();
    std::io::stdin().read_line(&mut nxy).ok();
    let nxy: Vec<usize> = nxy.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nxy[0];
    let x = nxy[1];
    let y = nxy[2];
    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 BITS = 18;
    let mut xop = vec![0usize; BITS];
    let mut yop = vec![0usize; BITS];
    for &v in a.iter() {
        for i in 0..BITS {
            xop[i] += (v >> i) & 1;
        }
    }
    for &v in b.iter() {
        for i in 0..BITS {
            yop[i] += (v >> i) & 1;
        }
    }
    let mut cnts = vec![0usize; BITS];
    let mut patterns = 1usize;
    for _ in 0..n {
        for i in 0..BITS {
            cnts[i] = cnts[i] * x % MOD + xop[i] * (MOD + patterns - cnts[i]) % MOD;
            cnts[i] %= MOD;
        }
        patterns *= x;
        patterns %= MOD;
        for i in 0..BITS {
            cnts[i] = cnts[i] * yop[i] % MOD;
        }
        patterns *= y;
        patterns %= MOD;
    }
    println!("{}", (0..BITS).map(|i| cnts[i] * (1usize << i) % MOD).sum::<usize>() % MOD)
}
0