結果

問題 No.1958 Bit Game
ユーザー phsplsphspls
提出日時 2022-09-28 11:17:42
言語 Rust
(1.77.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,433 bytes
コンパイル時間 12,968 ms
コンパイル使用メモリ 378,496 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-06-02 01:28:10
合計ジャッジ時間 15,694 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
9,472 KB
testcase_01 AC 46 ms
9,472 KB
testcase_02 AC 45 ms
9,472 KB
testcase_03 AC 45 ms
9,472 KB
testcase_04 AC 46 ms
9,472 KB
testcase_05 AC 45 ms
9,472 KB
testcase_06 AC 46 ms
9,600 KB
testcase_07 AC 45 ms
9,344 KB
testcase_08 AC 45 ms
9,472 KB
testcase_09 AC 46 ms
9,472 KB
testcase_10 AC 12 ms
5,376 KB
testcase_11 AC 22 ms
5,376 KB
testcase_12 AC 26 ms
6,656 KB
testcase_13 AC 27 ms
5,888 KB
testcase_14 AC 25 ms
5,376 KB
testcase_15 AC 26 ms
7,552 KB
testcase_16 AC 17 ms
5,632 KB
testcase_17 AC 38 ms
8,320 KB
testcase_18 AC 35 ms
8,320 KB
testcase_19 AC 21 ms
6,528 KB
testcase_20 AC 29 ms
5,376 KB
testcase_21 AC 28 ms
7,680 KB
testcase_22 AC 15 ms
5,376 KB
testcase_23 AC 14 ms
5,376 KB
testcase_24 AC 35 ms
7,168 KB
testcase_25 AC 18 ms
5,376 KB
testcase_26 AC 28 ms
5,376 KB
testcase_27 AC 24 ms
7,040 KB
testcase_28 AC 32 ms
6,528 KB
testcase_29 AC 17 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `BITS` should have a snake case name
  --> src/main.rs:18:9
   |
18 |     let BITS = 18;
   |         ^^^^ help: convert the identifier to snake case: `bits`
   |
   = note: `#[warn(non_snake_case)]` on by default

ソースコード

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