結果
問題 | No.870 無敵囲い |
ユーザー |
![]() |
提出日時 | 2019-08-30 22:13:55 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 300 ms |
コード長 | 878 bytes |
コンパイル時間 | 4,440 ms |
コンパイル使用メモリ | 169,600 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-29 06:20:13 |
合計ジャッジ時間 | 5,130 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
コンパイルメッセージ
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:19:47: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 19 | else let (c, d) = head xs | ^^^^ Main.hs:22:7: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 22 | | head xs == a && (head . tail) xs == b = check zs (zs:ys) k xss | ^^^^ Main.hs:22:24: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 22 | | head xs == a && (head . tail) xs == b = check zs (zs:ys) k xss | ^^^^ Main.hs:22:31: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 22 | | head xs == a && (head . tail) xs == b = check zs (zs:ys) k xss | ^^^^ [2 of 2] Linking a.out
ソースコード
main::IO()main = interact $ solve . map read . wordssplitEvery4::Int->IntsplitEvery4 = takeWhile (not . null) . map (take 4) . iterate (drop 4)solve::Int->Stringsolve (n:xs) = if all id [a, b, c] then "YES" else "NO"wherexss = splitEvery4 xsa = check (2, 8) [] (5, 8) xssb = check (3, 9) [] (4, 8) xssc = check (7, 9) [] (6, 8) xsscheck::IntInt->IntInt->IntInt->Int->Boolchcek _ [] _ [] = Falsecheck _ xs (a, b) [] = if null xsthen Falseelse let (c, d) = head xsin a == c && b == dcheck (a, b) ys k (xs:xss)| head xs == a && (head . tail) xs == b = check zs (zs:ys) k xss| otherwise = check (a, b) ys k xsswherezs = (\[x, y] -> (x, y)) $ drop 2 xs