fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } macro_rules! read { ($x:ident, $v:expr, $idx:expr, $type:ty) => { let $x:$type = $v[$idx].clone().parse().unwrap(); }; ( $($x:ident:$t:ty),* ) => { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let input:Vec = s.trim() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect(); let mut idx:i64 = -1; $( idx += 1; read!($x, input, idx as usize, $t); )* }; } fn main() { read!(H:usize, W:usize); let s:Vec> = (0..H).map(|_| { let line:String = read(); line.chars().map(|c| if c == '#' {1} else {0}).collect() }).collect(); let is_all_zero = |list: &Vec>| { for i in 0..list.len() { for j in 0..list[i].len() { if list[i][j] == 1 { return false; } } } true }; if is_all_zero(&s) { println!("NO"); } else { let mut dh_range: Vec = vec![]; let mut dw_range: Vec = vec![]; for i in 0..H { dh_range.push(-1*(i as i64)); dh_range.push(i as i64); } for i in 0..W { dw_range.push(-1*(i as i64)); dw_range.push(i as i64); } let mut result = "NO"; 'outer: for dh in &dh_range { for dw in &dw_range { if *dw == 0 && *dh == 0 { continue; } let mut check = s.clone(); for h in 0..H { for w in 0..W { let nh = h as i64 + dh; let nw = w as i64 + dw; if nh >= 0 && nh < H as i64 && nw >= 0 && nw < W as i64 && check[h][w] == 1 && check[nh as usize][nw as usize] == 1 { check[h][w] = 0; check[nh as usize][nw as usize] = 0; } } } if is_all_zero(&check) { result = "YES"; break 'outer; } } } println!("{}", result); } }