結果
問題 | No.1516 simple 門松列 problem Re:MASTER |
ユーザー | koba-e964 |
提出日時 | 2021-12-11 10:46:21 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,184 bytes |
コンパイル時間 | 13,844 ms |
コンパイル使用メモリ | 379,612 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 11:02:53 |
合計ジャッジ時間 | 34,424 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
コンパイルメッセージ
warning: unused variable: `pw` --> src/main.rs:90:9 | 90 | let pw = squpow(&mat, n, MOD); | ^^ help: if this is intentional, prefix it with an underscore: `_pw` | = note: `#[warn(unused_variables)]` on by default
ソースコード
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::Read; #[allow(dead_code)] fn getline() -> String { let mut ret = String::new(); std::io::stdin().read_line(&mut ret).ok().unwrap(); ret } fn get_word() -> String { let stdin = std::io::stdin(); let mut stdin=stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec<u8> = Vec::with_capacity(16); loop { let res = stdin.read(&mut u8b); if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { break; } else { buf.push(u8b[0]); } } if buf.len() >= 1 { let ret = String::from_utf8(buf).unwrap(); return ret; } } } #[allow(dead_code)] fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() } fn squmul(a: &[Vec<i64>], b: &[Vec<i64>], mo: i64) -> Vec<Vec<i64>> { let n = a.len(); let mut ret = vec![vec![0; n]; n]; for i in 0..n { for j in 0..n { for k in 0..n { ret[i][k] += a[i][j] * b[j][k]; ret[i][k] %= mo; } } } ret } fn squpow(a: &[Vec<i64>], mut e: i64, mo: i64) -> Vec<Vec<i64>> { let n = a.len(); let mut sum = vec![vec![0; n]; n]; for i in 0..n { sum[i][i] = 1; } let mut cur = a.to_vec(); while e > 0 { if e % 2 == 1 { sum = squmul(&sum, &cur, mo); } cur = squmul(&cur, &cur, mo); e /= 2; } sum } const MOD: i64 = 998_244_353; fn solve() { let n: i64 = get(); let k: usize = get(); let mut mat = vec![vec![0; 4 * k * k]; 4 * k * k]; for a in 0..k { for b in 0..k { for c in 0..k { if c == a { continue; } if a > b { mat[b * k + c][k * k + a * k + b] += 1; mat[2 * k * k + b * k + c][3 * k * k + a * k + b] += 1; mat[b * k + c][3 * k * k + a * k + b] += a as i64 + 1; } if a < b { mat[k * k + b * k + c][a * k + b] += 1; mat[3 * k * k + b * k + c][2 * k * k + a * k + b] += 1; mat[k * k + b * k + c][2 * k * k + a * k + b] += a as i64 + 1; } } } } let pw = squpow(&mat, n, MOD); let mut ans1 = 0; let mut ans2 = 0; for a in 0..k { for b in 0..k { if a != b { for c in 0..2 * k { for d in 0..k { if c % k != d { ans1 = (ans1 + mat[a * k + b][c * k + d]) % MOD; ans2 = (ans2 + mat[a * k + b][2 * k * k + c * k + d]) % MOD; } } } } } } println!("{} {}", ans1, ans2); } fn main() { // In order to avoid potential stack overflow, spawn a new thread. let stack_size = 104_857_600; // 100 MB let thd = std::thread::Builder::new().stack_size(stack_size); thd.spawn(|| solve()).unwrap().join().unwrap(); }