結果

問題 No.197 手品
ユーザー ducktail
提出日時 2018-05-15 23:16:16
言語 Haskell
(9.10.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 673 bytes
コンパイル時間 3,392 ms
コンパイル使用メモリ 174,208 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 03:54:20
合計ジャッジ時間 3,988 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative ((<$>), (<*>))
import Data.Bool (bool)

main :: IO ()
main = solve <$> getLine <*> readLn <*> getLine >>= putStrLn

solve :: String -> Int -> String -> String
solve [c1, c2, c3] n sa | n == 0 = bool "SUCCESS" "FAILURE"  $ sa == s0
                        | n == 1 = bool "SUCCESS" "FAILURE"  $ sa == s1 || sa == s2
                        | even n = bool "SUCCESS" "FAILURE"  $ sa `elem` [s0, s3, s4]
                        | otherwise = bool "SUCCESS" "FAILURE"  $ sa `elem` [s1, s2, s5]
  where s0 = [c1, c2, c3]
        s1 = [c2, c1, c3]
        s2 = [c1, c3, c2]
        s3 = [c2, c3, c1]
        s4 = [c3, c1, c2]
        s5 = [c3, c2, c1]
0