結果

問題 No.179 塗り分け
ユーザー hatoo
提出日時 2017-11-13 15:22:25
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 2,977 bytes
コンパイル時間 14,421 ms
コンパイル使用メモリ 387,888 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 00:25:46
合計ジャッジ時間 13,633 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 34 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#[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();

    for dy in 0..h {
        'dx: for dx in 0..w {
            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 + dx < w && t[y + dy][x + dx] {
                        t[y][x] = false;
                        t[y + dy][x + dx] = false;
                    } else {
                        // debug!(dy, dx, y, x, &t);
                        continue 'dx;
                    }
                }
            }
            println!("YES");
            return;
        }
    }

    println!("NO");
}
0