結果
問題 | No.179 塗り分け |
ユーザー |
![]() |
提出日時 | 2017-03-24 14:01:16 |
言語 | Haskell (9.10.1) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,496 bytes |
コンパイル時間 | 142 ms |
コンパイル使用メモリ | 148,736 KB |
最終ジャッジ日時 | 2024-11-15 04:44:50 |
合計ジャッジ時間 | 641 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:1:1: error: [GHC-87110] Could not load module ‘Data.Map’. It is a member of the hidden package ‘containers-0.6.8’. Use -v to see a list of the files searched for. | 1 | import Data.Map hiding (map) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
importData.MaphidingmapimportData.MaybeimportControl.MonadimportPreludehidinglookup,nulltype Board = Map (Int,Int) (Maybe Bool)test1 = concat["######...\n","#.####.#.\n","######...\n"]test2 = concat["..............##................\n","..........##########............\n","......##################........\n","..##########################....\n","##....##################....##..\n","######....##########....######..\n","##########....##....##########..\n","##....########..##############..\n","######....####..##############..\n","##############..##############..\n","##############..##############..\n","##############..##############..\n","..############..############....\n","......########..########........\n","..........####..####............\n","..............##................\n"]main = do[m,n] <- map read . words <$> getLine :: IO [Int]c <- getContentsputStrLn $ if isSeparatable (m,n) (genBoard c) then "YES" else "NO"genBoard::String->BoardgenBoard = gBRow 0 . lineswheregBRow _ [] = emptygBRow n (line:ls) = gBCol (gBRow (n+1) ls) (n,0) linegBCol b _ [] = bgBCol b (n,m) (square:ss) =if square=='#'then insert (n,m) Nothing b'else b'whereb' = gBCol b (n,m+1) ssshowBoard::IntInt->Board->StringshowBoard (n,m) b = sBRow 0wheresBRow n' | n'<n = sBCol (n',0) ++ sBRow (n'+1)| otherwise = []sBCol pos@(n',m') | m'<m =case lookup pos b ofNothing -> '.':restJust Nothing -> '#':restJust (Just True) -> 'X':restJust (Just False) -> 'O':rest| otherwise = "\n"whererest = sBCol (n',m'+1)colorBoard::IntInt->Board->MaybeBoardcolorBoard (m,n) b = cB b $ keys bwherecB b' [] = Just b'cB b' ((m',n'):ps) =case b'!(m',n') ofNothing ->case lookup (m'+m,n'+n) b' ofJust Nothing -> cB (insert (m'+m,n'+n) (Just False) $ insert (m',n') (Just True) b') ps_ -> NothingJust False -> cB b' psisSeparatable::IntInt->Board->BoolisSeparatable (m,n) b = (&&) (not $ null b) $ or $ isJust <$> (colorBoard <$> [(x,y)|x<-[0..m],y<-[-n..n],x/=0||y/=0] <*> [b])--isSeparatable (m,n) b = (||) (null b) $ or $ isJust <$> (colorBoard <$> (tail [(x,y)|x<-[0..m],y<-[-n..n]] ++ [(x,y)|x<-[0..m],y<-[-1..(-n)]]) <*>[b])