結果
問題 |
No.1958 Bit Game
|
ユーザー |
|
提出日時 | 2022-09-22 01:45:54 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 1,418 bytes |
コンパイル時間 | 18,351 ms |
コンパイル使用メモリ | 379,564 KB |
実行使用メモリ | 9,472 KB |
最終ジャッジ日時 | 2024-12-22 04:35:09 |
合計ジャッジ時間 | 21,846 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
コンパイルメッセージ
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
ソースコード
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); }