結果

問題 No.1958 Bit Game
ユーザー phsplsphspls
提出日時 2022-09-22 01:45:54
言語 Rust
(1.77.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,418 bytes
コンパイル時間 4,182 ms
コンパイル使用メモリ 142,936 KB
実行使用メモリ 9,392 KB
最終ジャッジ日時 2023-08-23 20:17:59
合計ジャッジ時間 7,532 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
9,384 KB
testcase_01 AC 50 ms
9,304 KB
testcase_02 AC 51 ms
9,332 KB
testcase_03 AC 50 ms
9,384 KB
testcase_04 AC 50 ms
9,296 KB
testcase_05 AC 50 ms
9,392 KB
testcase_06 AC 50 ms
9,304 KB
testcase_07 AC 50 ms
9,376 KB
testcase_08 AC 50 ms
9,348 KB
testcase_09 AC 51 ms
9,376 KB
testcase_10 AC 14 ms
4,380 KB
testcase_11 AC 25 ms
5,372 KB
testcase_12 AC 28 ms
6,520 KB
testcase_13 AC 30 ms
5,812 KB
testcase_14 AC 27 ms
5,420 KB
testcase_15 AC 26 ms
7,472 KB
testcase_16 AC 17 ms
5,660 KB
testcase_17 AC 41 ms
8,196 KB
testcase_18 AC 37 ms
8,124 KB
testcase_19 AC 22 ms
6,264 KB
testcase_20 AC 33 ms
5,188 KB
testcase_21 AC 29 ms
7,744 KB
testcase_22 AC 19 ms
4,376 KB
testcase_23 AC 15 ms
4,772 KB
testcase_24 AC 39 ms
7,112 KB
testcase_25 AC 19 ms
4,920 KB
testcase_26 AC 31 ms
5,448 KB
testcase_27 AC 23 ms
7,052 KB
testcase_28 AC 37 ms
6,184 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,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `SIZE` should have a snake case name
  --> Main.rs:18:9
   |
18 |     let SIZE = 19;
   |         ^^^^ help: convert the identifier to snake case: `size`
   |
   = 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 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