結果
| 問題 |
No.149 碁石の移動
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-07 19:45:35 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 1,392 bytes |
| コンパイル時間 | 10,654 ms |
| コンパイル使用メモリ | 169,984 KB |
| 実行使用メモリ | 23,168 KB |
| 最終ジャッジ日時 | 2024-12-23 20:54:15 |
| 合計ジャッジ時間 | 6,862 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 |
コンパイルメッセージ
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)