結果

問題 No.26 シャッフルゲーム
ユーザー 情報学生情報学生
提出日時 2019-08-15 16:16:41
言語 Haskell
(9.6.2)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 336 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 165,788 KB
実行使用メモリ 6,576 KB
最終ジャッジ日時 2023-10-19 19:05:15
合計ジャッジ時間 2,871 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,112 KB
testcase_01 AC 3 ms
5,124 KB
testcase_02 AC 4 ms
6,576 KB
testcase_03 AC 3 ms
5,552 KB
testcase_04 AC 3 ms
5,904 KB
testcase_05 AC 3 ms
6,044 KB
testcase_06 AC 3 ms
6,184 KB
testcase_07 AC 3 ms
5,876 KB
testcase_08 AC 3 ms
6,392 KB
testcase_09 AC 4 ms
6,576 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

main :: IO ()
main = interact $ show . solve . map read . words

splitEvery2 :: [Int] -> [[Int]]
splitEvery2 = takeWhile (not . null) . map (take 2) . iterate (drop 2)

solve :: [Int] -> Int
solve (n:m:xs) = foldl (\n -> \t -> if head t == n then last t else if last t == n then head t else n) n ys
    where
        ys = splitEvery2 xs
0