結果
| 問題 |
No.1434 Make Maze
|
| コンテスト | |
| ユーザー |
Strorkis
|
| 提出日時 | 2021-03-20 18:04:12 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,604 bytes |
| コンパイル時間 | 14,106 ms |
| コンパイル使用メモリ | 396,512 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 06:41:04 |
| 合計ジャッジ時間 | 19,595 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 WA * 17 |
ソースコード
#[allow(dead_code)]
mod io {
use std::str::{FromStr, SplitWhitespace};
pub struct Scanner<'a>(pub SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
pub fn next<T: FromStr>(&mut self) -> T {
self.0.next().unwrap().parse().ok().unwrap()
}
}
pub fn vec<T, F: FnMut() -> T>(f: F, n: usize) -> Vec<T> {
std::iter::repeat_with(f).take(n).collect()
}
}
use std::io::Read;
fn main() {
let ref mut buf = String::new();
std::io::stdin().read_to_string(buf).ok();
let mut sc = io::Scanner(buf.split_whitespace());
let (h, w, x) = {
(sc.next::<usize>(), sc.next::<usize>(), sc.next::<usize>())
};
let (is_swapped, h, w) = {
if h % 4 == 3 { (true, w, h) } else { (false, h, w) }
};
if x < (h - 1) + (w - 1) {
return println!("-1");
}
let mut x = x - ((h - 1) + (w - 1));
let mut cell = vec![vec!['.'; w]; h];
for i in (1..h).step_by(2) {
for j in (1..w).step_by(2) {
cell[i][j] = '#';
}
}
for i in (1..h).step_by(2) {
if h % 4 == 3 && i + 2 == h {
for j in (1..w).step_by(2) {
if x >= 2 {
if j % 4 == 1 {
cell[i - 1][j] = '#';
} else {
cell[i + 1][j] = '#';
x -= 4;
}
} else {
cell[i - 1][j] = '#';
}
}
} else if i % 4 == 1 {
let mut done = false;
for j in (0..w).step_by(2) {
if done {
cell[i][j] = '#';
} else if j + 1 < w && x >= 4 {
cell[i][j] = '#';
} else {
done = true;
}
}
} else {
let mut done = false;
for j in (0..w).step_by(2).rev() {
if done {
cell[i][j] = '#';
} else if j > 0 && x >= 4 {
cell[i][j] = '#';
x -= 4;
} else {
done = true;
}
}
}
}
if x > 0 {
return println!("-1");
}
if is_swapped {
for j in 0..w {
for i in 0..h {
print!("{}", cell[i][j]);
}
println!();
}
} else {
for i in 0..h {
for j in 0..w {
print!("{}", cell[i][j]);
}
println!();
}
}
}
Strorkis