結果

問題 No.587 七対子
ユーザー OldBrid21501053OldBrid21501053
提出日時 2019-08-27 16:59:58
言語 Haskell
(9.8.2)
結果
RE  
実行時間 -
コード長 433 bytes
コンパイル時間 3,194 ms
コンパイル使用メモリ 171,392 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 17:49:54
合計ジャッジ時間 4,252 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 1 ms
6,940 KB
testcase_03 RE -
testcase_04 AC 1 ms
6,940 KB
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 WA -
testcase_29 RE -
testcase_30 AC 2 ms
6,944 KB
testcase_31 RE -
testcase_32 AC 1 ms
6,944 KB
testcase_33 AC 1 ms
6,940 KB
testcase_34 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:12:13: 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."
   |
12 |         z = head y
   |             ^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List (sort)

solve :: String -> String
solve s = if x /= 1
            then "Impossible"
            else if (length $ filter (== z) s) > 1
                then "Impossible"
                else y
    where
        x = length y
        y = f $ sort s
        z = head y
f :: String -> String
f [] = []
f (x:y:zs)  | x == y    = f zs
            | otherwise = x : f (y:zs)
main :: IO ()
main = getLine >>= putStrLn . solve
0