結果
| 問題 | No.945 YKC饅頭 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-11 00:03:58 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,368 bytes |
| 記録 | |
| コンパイル時間 | 3,557 ms |
| コンパイル使用メモリ | 149,632 KB |
| 最終ジャッジ日時 | 2024-06-24 02:44:09 |
| 合計ジャッジ時間 | 4,637 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:4:1: error: [GHC-87110]
Could not load module ‘Data.Set’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
4 | import qualified Data.Set as S
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
{-# LANGUAGE OverloadedStrings #-}
import Data.List (sort)
import Data.Maybe (fromJust)
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
main = B.interact $ solve . (\(x:xs) -> (x, zip [0..] $ map parse xs)) . B.lines
readInt = fst . fromJust . B.readInt
parse = (\(a:b:c:_) -> ([readInt a, readInt b], B.head c) :: ([Int], Char)) . B.words
solve (ns, xs) = B.pack . unwords . map show $ (\(a,b,c) -> [a, b, c]) ans
where
n = readInt . head $ B.words ns
ys = sort $ map (\e -> (head . fst $ snd e, e)) xs
r = (n+1,(length xs, ([n,n], 'X')))
(ans,_,_) = foldl f ((0,0,0), 1, S.empty) (ys ++ [r])
f a@(c, i, s) y@(j, e)
| i == j = (c, i, (S.insert e s))
| otherwise = f (g a) y
g (c@(yc, kc, cc), i, s) = (c2, i+1, s2)
where
h s = case S.minView s of
Just ((_, ([_, b], _)), t)
| b >= i -> s
| otherwise -> h t
_ -> s
s2 = h s
c2 = case S.lookupMin s2 of
Just (_, (_, 'Y')) -> (yc+1,kc,cc)
Just (_, (_, 'K')) -> (yc,kc+1,cc)
Just (_, (_, 'C')) -> (yc,kc,cc+1)
_ -> c