import Data.Char import Data.Bool import Data.List import Data.Maybe import Control.Monad import Data.IntMap ((!)) import qualified Data.IntMap as M main = do [h,w] <- map read . words <$> getLine cs <- filter isPrint <$> getContents let is = map fst $ filter ((=='#').snd) (zip [1000*h' + w' | h'<-[0..h-1], w'<-[0..w-1]] cs) putStrLn $ bool "NO" "YES" (dpaint h w (M.fromDistinctAscList (zip is (repeat False)))) dpaint h w icm | M.null icm = False | otherwise = or $ map (\d -> isJust (foldl' (paint d) (return icm) idx)) ds where idx = M.keys icm ds = [i | h'<-[0..h-1], w'<-[negate (w-1) .. w-1], let i = 1000*h'+w', i>0] paint _ Nothing _ = Nothing paint d (Just icm) i | icm ! i = return icm | (not . M.member (i+d)) icm = Nothing | otherwise = return (M.unionWith (||) (M.fromList [(i,True),(i+d,True)]) icm)