結果
| 問題 |
No.447 ゆきこーだーの雨と雪 (2)
|
| ユーザー |
atuk721
|
| 提出日時 | 2017-02-13 05:30:06 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,051 bytes |
| コンパイル時間 | 3,388 ms |
| コンパイル使用メモリ | 148,736 KB |
| 最終ジャッジ日時 | 2024-12-29 17:21:20 |
| 合計ジャッジ時間 | 4,142 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:6:1: error: [GHC-87110]
Could not load module ‘Data.Map’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
6 | import qualified Data.Map as M
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import qualified Control.Monad as Mo
import qualified Control.Monad.State as S
import qualified Data.Char as C
import qualified Data.Ord as O
import qualified Data.List as L
import qualified Data.Map as M
type Order = M.Map String ([Int], [Int])
type Answer = M.Map Char Int
data ProcState = ProcState {order :: Order, answer :: Answer} deriving Show
main :: IO ()
main = do
examN <- readLn :: IO Int
levels <- fmap (map read . words) getLine :: IO [Int]
submitN <- readLn :: IO Int
submits <- fmap lines getContents
let answers = M.fromList . zip (take examN ['A'..]) $ repeat 0
resultS = Mo.forM (zip [1..] submits) $ \(count, submit) -> do
s <- S.get
let o = order s
a = answer s
[name, levelC:[]] = words submit
(levelIndex, level) = getLevel levels levelC
rank = (M.!) a levelC + 1
score = floor $ 50 * (realToFrac level) + 50 * (realToFrac level) / (0.8 + 0.2 * (realToFrac rank))
(scores, answers) = case M.lookup name o of
Just (ss, as) -> (ss, as)
Nothing -> (replicate examN 0, [])
scores' = take levelIndex scores ++ (score : drop (levelIndex + 1) scores)
o' = M.insert name (scores', count:answers) o
a' = M.insert levelC rank a
S.put $ ProcState o' a'
result = M.toList . order . S.execState resultS $ ProcState M.empty answers
result' = L.sortBy compareResult result
Mo.forM_ (zip [1..] result') $ \(n, (name, (scores, _))) -> do
putStrLn $ show n ++ " " ++ name ++ " " ++ (unwords $ map show scores) ++ " " ++ show (sum scores)
getLevel :: [Int] -> Char -> (Int, Int)
getLevel levels c = (index, levels !! index)
where index = C.ord c - C.ord 'A'
compareResult :: (String, ([Int], [Int])) -> (String, ([Int], [Int])) -> Ordering
compareResult (_, (ss, o)) (_, (ss', o')) = if c /= EQ then c else O.comparing head o o'
where c = O.comparing sum ss' ss
atuk721