結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-13 15:33:36 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 3,000 ms |
| コード長 | 3,218 bytes |
| コンパイル時間 | 13,315 ms |
| コンパイル使用メモリ | 384,376 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-23 14:44:37 |
| 合計ジャッジ時間 | 14,226 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
use std::io::stdin;
use std::str::FromStr;
use std::fmt::Debug;
#[allow(dead_code)]
pub fn line() -> String {
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.trim().to_string()
}
#[allow(dead_code)]
pub fn gets<T: FromStr>() -> Vec<T>
where
<T as FromStr>::Err: Debug,
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.split_whitespace()
.map(|t| t.parse().unwrap())
.collect()
}
}
#[allow(unused_macros)]
macro_rules! get {
($t:ty) => {
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.trim().parse::<$t>().unwrap()
}
};
($($t:ty),*) => {
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
let mut iter = line.split_whitespace();
(
$(iter.next().unwrap().parse::<$t>().unwrap(),)*
)
}
};
($t:ty; $n:expr) => {
(0..$n).map(|_|
get!($t)
).collect::<Vec<_>>()
};
($($t:ty),*; $n:expr) => {
(0..$n).map(|_|
get!($($t),*)
).collect::<Vec<_>>()
};
($t:ty ;;) => {
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.split_whitespace()
.map(|t| t.parse::<$t>().unwrap())
.collect::<Vec<_>>()
}
};
}
#[allow(unused_macros)]
macro_rules! debug {
($($a:expr),*) => {
println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
}
}
fn main() {
let (h, w) = get!(usize, usize);
let ss: Vec<Vec<bool>> = (0..h)
.map(|_| util::line().chars().map(|c| c == '#').collect())
.collect();
if !ss.iter().any(|v| v.iter().any(|&b| b)) {
println!("NO");
return;
}
for dy in 0..h {
'dx: for dx in -(w as i64) as i64 + 1..w as i64 {
if dx == 0 && dy == 0 {
continue;
}
let mut t = ss.clone();
for y in 0..h {
for x in 0..w {
if !t[y][x] {
continue;
}
if t[y][x] && y + dy < h && x as i64 + dx >= 0 && x as i64 + dx < w as i64 &&
t[y + dy][(x as i64 + dx) as usize]
{
t[y][x] = false;
t[y + dy][(x as i64 + dx) as usize] = false;
} else {
// debug!(dy, dx, y, x, &t);
continue 'dx;
}
}
}
println!("YES");
return;
}
}
println!("NO");
}