結果
問題 | No.149 碁石の移動 |
ユーザー | iwot |
提出日時 | 2020-06-07 19:45:35 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 1,392 bytes |
コンパイル時間 | 7,844 ms |
コンパイル使用メモリ | 170,112 KB |
実行使用メモリ | 22,912 KB |
最終ジャッジ日時 | 2024-06-06 07:41:01 |
合計ジャッジ時間 | 6,632 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
8,320 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 8 ms
10,624 KB |
testcase_06 | AC | 10 ms
12,544 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 5 ms
7,168 KB |
testcase_11 | AC | 8 ms
10,880 KB |
testcase_12 | AC | 4 ms
7,424 KB |
testcase_13 | AC | 4 ms
7,680 KB |
testcase_14 | AC | 5 ms
8,064 KB |
testcase_15 | AC | 20 ms
18,816 KB |
testcase_16 | AC | 44 ms
22,912 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 ) [2 of 2] Linking a.out
ソースコード
main :: IO () main = do [aw,ab] <- map read . words <$> getLine [bw,bb] <- map read . words <$> getLine [c,d] <- map read . words <$> getLine print $ solve aw ab bw bb c d solve :: Int -> Int -> Int -> Int -> Int -> Int -> Int solve aw ab bw bb c d = white (fst $ fst b) where a = fukuroA ((White aw),(Black ab)) ((White bw),(Black bb)) c b = uncurry fukuroB a d white :: White -> Int white (White n) = n data White = White Int deriving (Show, Eq) data Black = Black Int deriving (Show, Eq) fukuroA :: (White, Black) -> (White, Black) -> Int -> ((White, Black), (White, Black)) fukuroA (w1,b1) (w2,b2) 0 = ((w1,b1), (w2,b2)) fukuroA (White 0, Black 0) (w2, b2) t = ((White 0, Black 0), (w2, b2)) fukuroA (White w1, Black 0) (White w2, b2) t = fukuroA (White (w1 - 1), Black 0) (White (w2+1), b2) (t-1) fukuroA (w1, Black b1) (w2, Black b2) t = fukuroA (w1, Black (b1-1)) (w2, Black (b2 + 1)) (t - 1) fukuroB :: (White, Black) -> (White, Black) -> Int -> ((White, Black), (White, Black)) fukuroB (w1, b1) (w2, b2) 0 = ((w1, b1), (w2, b2)) fukuroB (w1, b1) (White 0, Black 0) t = ((w1, b1), (White 0, Black 0)) fukuroB (w1, Black b1) (White 0, Black b2) t = fukuroB (w1, Black (b1+1)) (White 0, Black (b2-1)) (t-1) fukuroB (White w1, b1) (White w2, b2) t = fukuroB (White (w1+1), b1) (White (w2-1), b2) (t - 1)