結果

問題 No.1 道のショートカット
ユーザー aimyaimy
提出日時 2017-05-03 21:24:34
言語 Haskell
(9.8.2)
結果
AC  
実行時間 242 ms / 5,000 ms
コード長 582 bytes
コンパイル時間 972 ms
コンパイル使用メモリ 182,180 KB
実行使用メモリ 30,004 KB
最終ジャッジ日時 2023-09-27 22:05:01
合計ジャッジ時間 4,202 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,824 KB
testcase_01 AC 3 ms
7,776 KB
testcase_02 AC 2 ms
7,864 KB
testcase_03 AC 3 ms
8,088 KB
testcase_04 AC 2 ms
7,832 KB
testcase_05 AC 2 ms
7,892 KB
testcase_06 AC 2 ms
8,004 KB
testcase_07 AC 2 ms
8,196 KB
testcase_08 AC 52 ms
13,880 KB
testcase_09 AC 22 ms
12,708 KB
testcase_10 AC 52 ms
13,604 KB
testcase_11 AC 92 ms
15,764 KB
testcase_12 AC 242 ms
18,560 KB
testcase_13 AC 232 ms
19,044 KB
testcase_14 AC 4 ms
9,644 KB
testcase_15 AC 2 ms
7,596 KB
testcase_16 AC 7 ms
12,076 KB
testcase_17 AC 2 ms
7,800 KB
testcase_18 AC 4 ms
9,848 KB
testcase_19 AC 3 ms
9,284 KB
testcase_20 AC 22 ms
12,652 KB
testcase_21 AC 5 ms
10,932 KB
testcase_22 AC 4 ms
9,368 KB
testcase_23 AC 172 ms
30,004 KB
testcase_24 AC 142 ms
29,748 KB
testcase_25 AC 22 ms
13,876 KB
testcase_26 AC 12 ms
12,672 KB
testcase_27 AC 192 ms
21,560 KB
testcase_28 AC 3 ms
7,992 KB
testcase_29 AC 52 ms
14,796 KB
testcase_30 AC 12 ms
12,228 KB
testcase_31 AC 22 ms
13,448 KB
testcase_32 AC 52 ms
14,620 KB
testcase_33 AC 22 ms
12,852 KB
testcase_34 AC 142 ms
19,624 KB
testcase_35 AC 12 ms
12,960 KB
testcase_36 AC 22 ms
12,904 KB
testcase_37 AC 22 ms
12,784 KB
testcase_38 AC 3 ms
8,972 KB
testcase_39 AC 5 ms
10,444 KB
testcase_40 AC 8 ms
12,220 KB
testcase_41 AC 4 ms
10,072 KB
testcase_42 AC 2 ms
7,704 KB
testcase_43 AC 2 ms
7,516 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 Data.Map ((!))
import qualified Data.Map as M
import Data.List

main = do
 n <- readLn
 c <- readLn
 getLine
 styms <- transpose . map (map read . words) . lines <$> getContents
 print (shortcut n c styms)

shortcut n c = result . foldl move (M.singleton (1,c) 0) . sort
 where
  minimum' xs = if null xs then -1 else minimum xs
  result im = minimum' $ M.elems $ M.filterWithKey (\(n',_) _ -> n'==n) im 

move im [s,t,y,m] = M.unionWith min im $ M.filterWithKey (\(_,c') _ -> c'>=0) $
 M.mapKeys (\(n',c') -> (t,c'-y)) $ M.map (+m) $ M.filterWithKey (\(n',_) _ -> n'==s) im
0