結果

問題 No.26 シャッフルゲーム
ユーザー e7a894e7a894
提出日時 2020-09-17 15:50:49
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 377 bytes
コンパイル時間 8,894 ms
コンパイル使用メモリ 160,904 KB
実行使用メモリ 8,596 KB
最終ジャッジ日時 2023-09-04 07:17:12
合計ジャッジ時間 9,910 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,980 KB
testcase_01 AC 3 ms
6,992 KB
testcase_02 AC 4 ms
8,596 KB
testcase_03 AC 4 ms
7,572 KB
testcase_04 AC 4 ms
7,896 KB
testcase_05 AC 4 ms
8,004 KB
testcase_06 AC 3 ms
8,192 KB
testcase_07 AC 3 ms
7,812 KB
testcase_08 AC 4 ms
8,388 KB
testcase_09 AC 4 ms
8,528 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Monad

main = do
  n <- readLn
  m <- readLn
  ws <- replicateM m $ map read . words <$> getLine :: IO [[Int]]
  -- putStrLn . show $ n + 0
  -- putStrLn . show $ m + 0
  -- print ws
  putStrLn . show $ solve n ws
  
solve a ([x,y]:ws)
  | ws == [] = check a x y
  | otherwise = solve (check a x y) ws

check a x y
  | a == x = y
  | a == y = x
  | otherwise = a
0