結果
| 問題 |
No.1797 永遠のグリッド
|
| ユーザー |
fukafukatani
|
| 提出日時 | 2022-01-01 16:25:14 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,562 bytes |
| コンパイル時間 | 11,934 ms |
| コンパイル使用メモリ | 401,712 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-10 07:22:48 |
| 合計ジャッジ時間 | 13,169 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 1 |
| other | AC * 10 WA * 4 RE * 13 |
ソースコード
#![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::<i128>();
let (h, w, k) = (v[0], v[1], v[2]);
if k == 1 {
println!("1");
return;
}
if k == 2 {
let total = 2i128.pow((h * w) as u32) - 2;
let raw_same = 2i128.pow(h as u32) - 2;
let col_same = 2i128.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 = 3i128.pow((h * w) as u32) - 3 * 2i128.pow((h * w) as u32) + 3;
let raw_same = 3i128.pow(h as u32) - 3 * 2i128.pow(h as u32) + 3;
let col_same = 3i128.pow(w as u32) - 3 * 2i128.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()
}
fukafukatani