結果
問題 | No.1434 Make Maze |
ユーザー | fukafukatani |
提出日時 | 2021-03-19 22:59:59 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,655 bytes |
コンパイル時間 | 14,811 ms |
コンパイル使用メモリ | 390,568 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-11-19 00:34:04 |
合計ジャッジ時間 | 18,173 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 1 ms
6,820 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
6,820 KB |
testcase_05 | AC | 1 ms
6,816 KB |
testcase_06 | AC | 1 ms
6,816 KB |
testcase_07 | AC | 1 ms
6,816 KB |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
6,820 KB |
testcase_10 | AC | 1 ms
6,820 KB |
testcase_11 | AC | 1 ms
6,820 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
6,816 KB |
testcase_21 | AC | 1 ms
6,816 KB |
testcase_22 | AC | 1 ms
6,820 KB |
testcase_23 | AC | 1 ms
6,816 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 `reduced` is assigned to, but never used --> src/main.rs:28:13 | 28 | let mut reduced = false; | ^^^^^^^ | = note: consider using `_reduced` instead = note: `#[warn(unused_variables)]` on by default warning: value assigned to `reduced` is never read --> src/main.rs:30:9 | 30 | reduced = true; | ^^^^^^^ | = help: maybe it is overwritten before being read? = note: `#[warn(unused_assignments)]` on by default
ソースコード
#![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 { if y % 2 == 0 { used.push((x, y)); } } } else { for y in (1..h).rev() { if y % 2 == 0 { used.push((x, y)); } } } } debug!(used); used.reverse(); let mut added = vec![]; let mut cur = max_len; while cur > max_len { 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] = '#'; } } } if swapped { for x in 0..w { for y in 0..h { print!("{}", grid[y][x]); } println!(""); } } else { 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() }