結果

問題 No.1958 Bit Game
ユーザー phsplsphspls
提出日時 2022-09-22 01:45:54
言語 Rust
(1.77.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,418 bytes
コンパイル時間 21,862 ms
コンパイル使用メモリ 386,352 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2024-06-01 17:41:53
合計ジャッジ時間 17,035 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
9,472 KB
testcase_01 AC 46 ms
9,344 KB
testcase_02 AC 46 ms
9,472 KB
testcase_03 AC 46 ms
9,472 KB
testcase_04 AC 46 ms
9,472 KB
testcase_05 AC 46 ms
9,472 KB
testcase_06 AC 45 ms
9,472 KB
testcase_07 AC 45 ms
9,472 KB
testcase_08 AC 45 ms
9,472 KB
testcase_09 AC 46 ms
9,472 KB
testcase_10 AC 12 ms
6,940 KB
testcase_11 AC 23 ms
6,940 KB
testcase_12 AC 26 ms
6,940 KB
testcase_13 AC 27 ms
6,940 KB
testcase_14 AC 25 ms
6,944 KB
testcase_15 AC 25 ms
7,680 KB
testcase_16 AC 17 ms
6,940 KB
testcase_17 AC 38 ms
8,192 KB
testcase_18 AC 35 ms
8,192 KB
testcase_19 AC 21 ms
6,944 KB
testcase_20 AC 29 ms
6,944 KB
testcase_21 AC 28 ms
7,808 KB
testcase_22 AC 15 ms
6,944 KB
testcase_23 AC 15 ms
6,944 KB
testcase_24 AC 35 ms
7,168 KB
testcase_25 AC 17 ms
6,940 KB
testcase_26 AC 27 ms
6,944 KB
testcase_27 AC 22 ms
7,040 KB
testcase_28 AC 32 ms
6,940 KB
testcase_29 AC 17 ms
6,944 KB
testcase_30 AC 1 ms
6,944 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `SIZE` should have a snake case name
  --> src/main.rs:18:9
   |
18 |     let SIZE = 19;
   |         ^^^^ help: convert the identifier to snake case: `size`
   |
   = 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 SIZE = 19;
    let mut acnt = vec![0usize; SIZE];
    let mut bcnt = vec![0usize; SIZE];
    for i in 0..x {
        for j in 0..SIZE {
            acnt[j] += (a[i] >> j) & 1;
        }
    }
    for i in 0..y {
        for j in 0..SIZE {
            bcnt[j] += (b[i] >> j) & 1;
        }
    }
    let mut dp = vec![0usize; SIZE];
    let mut patterns = 1usize;
    for _ in 0..n {
        for j in 0..SIZE {
            dp[j] = dp[j] * x % MOD + acnt[j] * (MOD + patterns - dp[j]) % MOD;
            dp[j] %= MOD;
        }
        patterns *= x;
        patterns %= MOD;
        for j in 0..SIZE {
            dp[j] = dp[j] * bcnt[j] % MOD;
        }
        patterns *= y;
        patterns %= MOD;
    }
    println!("{}", (0..SIZE).map(|i| dp[i] * (1usize<<i) % MOD).sum::<usize>() % MOD);
}
0