結果
問題 | No.1434 Make Maze |
ユーザー | fukafukatani |
提出日時 | 2021-03-19 23:10:29 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,445 bytes |
コンパイル時間 | 13,178 ms |
コンパイル使用メモリ | 386,440 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-19 01:09:59 |
合計ジャッジ時間 | 18,147 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 1 ms
5,248 KB |
testcase_06 | AC | 1 ms
5,248 KB |
testcase_07 | AC | 1 ms
5,248 KB |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | WA | - |
testcase_11 | AC | 1 ms
5,248 KB |
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 | AC | 1 ms
5,248 KB |
testcase_21 | AC | 1 ms
5,248 KB |
testcase_22 | AC | 1 ms
5,248 KB |
testcase_23 | AC | 1 ms
5,248 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
コンパイルメッセージ
warning: variable `swapped` is assigned to, but never used --> src/main.rs:21:13 | 21 | let mut swapped = false; | ^^^^^^^ | = note: consider using `_swapped` instead = note: `#[warn(unused_variables)]` on by default warning: value assigned to `swapped` is never read --> src/main.rs:23:9 | 23 | swapped = true; | ^^^^^^^ | = help: maybe it is overwritten before being read? = note: `#[warn(unused_assignments)]` on by default warning: variable `reduced` is assigned to, but never used --> src/main.rs:28:13 | 28 | let mut reduced = false; | ^^^^^^^ | = note: consider using `_reduced` instead warning: value assigned to `reduced` is never read --> src/main.rs:30:9 | 30 | reduced = true; | ^^^^^^^ | = help: maybe it is overwritten before being read?
ソースコード
#![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::<usize>(); let (mut h, mut w, x) = (v[0], v[1], v[2]); let mut swapped = false; if (w - 3) % 4 == 0 && (h - 3) % 4 != 0 { swapped = true; std::mem::swap(&mut h, &mut w); } let mut max_len = (h - 1) * (w + 1) / 2 + (w - 1); let mut reduced = false; if (w - 3) % 4 == 0 { reduced = true; max_len -= 2; } let min_len = h + w - 2; if x < min_len || x > max_len { println!("-1"); return; } if (x - min_len) % 4 != 0 { println!("-1"); return; } debug!(min_len, max_len); let mut used = vec![]; for x in 0..w { if x % 2 == 0 { continue; } if x % 4 == 1 { for y in (0..h - 1).rev() { if y % 2 == 0 { used.push((x, y)); } } } else { for y in 1..h { if y % 2 == 0 { used.push((x, y)); } } } } debug!(used); used.reverse(); let mut added = vec![]; let mut cur = max_len; while cur > x { let (x, y) = used.pop().unwrap(); if x % 4 == 1 { added.push((x, y + 2)); } else { added.push((x, y - 2)); } cur -= 4; } used.append(&mut added); let mut grid = vec![vec!['.'; w]; h]; for (x, y) in used { grid[y][x] = '#'; } for y in 0..h { for x in 0..w { if x % 2 == 1 && y % 2 == 1 { grid[y][x] = '#'; } } } for y in 0..h { for x in 0..w { print!("{}", grid[y][x]); } println!(""); } } 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() }