結果
問題 |
No.1797 永遠のグリッド
|
ユーザー |
![]() |
提出日時 | 2022-01-01 14:59:27 |
言語 | Rust (1.83.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,608 bytes |
コンパイル時間 | 13,071 ms |
コンパイル使用メモリ | 379,092 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-10 04:52:46 |
合計ジャッジ時間 | 14,185 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 |
other | AC * 9 WA * 3 RE * 15 |
ソースコード
#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let v = read_vec::<i64>(); let (h, w, k) = (v[0], v[1], v[2]); if k == 1 { println!("1"); return; } if h == 1 || w == 1 { assert!(false); } if k == 2 { let total = 2i64.pow((h * w) as u32) - 2; let raw_same = 2i64.pow(h as u32) - 2; let col_same = 2i64.pow(w as u32) - 2; let rc = raw_same + col_same; let ans = (total - rc) / (h * w) + raw_same / h + col_same / w; println!("{}", ans); return; } assert!(false); let total = 3i64.pow((h * w) as u32) - 3 * 2i64.pow((h * w) as u32) + 3; let raw_same = 3i64.pow(h as u32) - 3 * 2i64.pow(h as u32) + 3; let col_same = 3i64.pow(w as u32) - 3 * 2i64.pow(w as u32) + 3; let rc = raw_same + col_same; debug!(total, raw_same, col_same); let ans = (total - rc) / (h * w) + raw_same / h + col_same / w; println!("{}", ans); } fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }