結果
問題 | No.1958 Bit Game |
ユーザー | phspls |
提出日時 | 2022-09-15 01:01:12 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 93 ms / 2,000 ms |
コード長 | 2,276 bytes |
コンパイル時間 | 13,967 ms |
コンパイル使用メモリ | 379,808 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-05-09 04:29:28 |
合計ジャッジ時間 | 17,659 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 93 ms
11,008 KB |
testcase_01 | AC | 93 ms
11,136 KB |
testcase_02 | AC | 93 ms
11,136 KB |
testcase_03 | AC | 93 ms
10,880 KB |
testcase_04 | AC | 93 ms
11,008 KB |
testcase_05 | AC | 93 ms
11,008 KB |
testcase_06 | AC | 93 ms
11,008 KB |
testcase_07 | AC | 93 ms
11,008 KB |
testcase_08 | AC | 92 ms
11,008 KB |
testcase_09 | AC | 93 ms
10,880 KB |
testcase_10 | AC | 24 ms
6,944 KB |
testcase_11 | AC | 45 ms
6,940 KB |
testcase_12 | AC | 53 ms
7,296 KB |
testcase_13 | AC | 53 ms
6,944 KB |
testcase_14 | AC | 49 ms
6,944 KB |
testcase_15 | AC | 53 ms
7,808 KB |
testcase_16 | AC | 34 ms
6,940 KB |
testcase_17 | AC | 76 ms
9,600 KB |
testcase_18 | AC | 71 ms
9,088 KB |
testcase_19 | AC | 43 ms
6,940 KB |
testcase_20 | AC | 57 ms
6,940 KB |
testcase_21 | AC | 58 ms
8,192 KB |
testcase_22 | AC | 30 ms
6,940 KB |
testcase_23 | AC | 29 ms
6,944 KB |
testcase_24 | AC | 71 ms
8,576 KB |
testcase_25 | AC | 34 ms
6,940 KB |
testcase_26 | AC | 53 ms
6,940 KB |
testcase_27 | AC | 47 ms
7,040 KB |
testcase_28 | AC | 65 ms
7,808 KB |
testcase_29 | AC | 34 ms
6,940 KB |
testcase_30 | AC | 1 ms
6,940 KB |
testcase_31 | AC | 1 ms
6,944 KB |
testcase_32 | AC | 1 ms
6,940 KB |
コンパイルメッセージ
warning: function `power` is never used --> src/main.rs:4:4 | 4 | fn power(times: usize, target: &Vec<Vec<usize>>) -> Vec<Vec<usize>> { | ^^^^^ | = note: `#[warn(dead_code)]` on by default warning: function `calc` is never used --> src/main.rs:19:4 | 19 | fn calc(left: &Vec<Vec<usize>>, right: &Vec<Vec<usize>>) -> Vec<Vec<usize>> { | ^^^^ warning: variable `SIZE` should have a snake case name --> src/main.rs:46:9 | 46 | let SIZE = 18; | ^^^^ help: convert the identifier to snake case: `size` | = note: `#[warn(non_snake_case)]` on by default
ソースコード
const MOD: usize = 998244353; fn power(times: usize, target: &Vec<Vec<usize>>) -> Vec<Vec<usize>> { let n = target.len(); if times == 0 { let mut ret = vec![vec![0usize; n]; n]; for i in 0..n { ret[i][i] = 1; } return ret; } let base = power(times/2, target); if times % 2 == 1 { calc(&calc(&base, &base), target) } else { calc(&base, &base) } } fn calc(left: &Vec<Vec<usize>>, right: &Vec<Vec<usize>>) -> Vec<Vec<usize>> { let sizei = left.len(); let sizej = right[0].len(); let sizek = left[0].len(); let mut ret = vec![vec![0usize; sizej]; sizei]; for i in 0..sizei { for j in 0..sizej { ret[i][j] = (0..sizek).map(|k| left[i][k] * right[k][j] % MOD).sum::<usize>() % MOD; } } ret } 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 = 18; let mut pct = vec![0usize; SIZE]; let mut tute = vec![0usize; SIZE]; for &v in a.iter() { for i in 0..SIZE { if ((v >> i) & 1) == 1 { pct[i] += 1; } } } for &v in b.iter() { for i in 0..SIZE { if ((v >> i) & 1) == 1 { tute[i] += 1; } } } let mut patterns = vec![1usize; n+1]; for i in 0..n { patterns[i+1] = patterns[i] * x % MOD * y % MOD; } let mut op = vec![0usize; SIZE]; for pat in 0..n { for i in 0..SIZE { op[i] = op[i] * pct[i] % MOD + (MOD + patterns[pat] - op[i]) * pct[i] % MOD + (x - pct[i]) * op[i] % MOD; op[i] %= MOD; op[i] = op[i] * tute[i] % MOD; } } println!("{}", (0..SIZE).map(|i| op[i] * (1 << i) % MOD).sum::<usize>() % MOD); }