Submission #12067157
Source Code Expand
import Control.Exception (assert) import Control.Monad import qualified Control.Monad.ST as ST import qualified Data.Array.IO as IO import qualified Data.Array.ST as ST import qualified Data.Array.Unboxed as A import Data.Bits import qualified Data.ByteString.Char8 as BS import Data.Char import Data.Foldable import Data.List import Data.Maybe import qualified Data.Sequence as Seq import qualified Data.Vector.Unboxed as V import qualified Data.Vector.Unboxed.Mutable as VM import Debug.Trace readInt = fst . fromJust . BS.readInt readIntList = map readInt . BS.words getInt = readInt <$> BS.getLine getIntList = readIntList <$> BS.getLine getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine readInteger = fst . fromJust . BS.readInteger readIntegerList = map readInteger . BS.words getInteger = readInteger <$> BS.getLine getIntegerList = readIntegerList <$> BS.getLine warshallFloyd :: A.UArray (Int, Int) Int -> A.UArray (Int, Int) Int warshallFloyd iarr = oarr where l = (fst . fst . A.bounds) iarr l' = (snd . fst . A.bounds) iarr r = (fst . snd . A.bounds) iarr r' = (snd . snd . A.bounds) iarr oarr = assert (l==l' && r==r') $ ST.runSTUArray $ do d <- ST.thaw iarr forM_ [l..r] $ \k -> forM_ [l..r] $ \i -> forM_ [l..r] $ \j -> do dik <- ST.readArray d (i,k) dkj <- ST.readArray d (k,j) dij <- ST.readArray d (i,j) when (dik + dkj < dij) $ ST.writeArray d (i,j) (dik + dkj) return d main = do [n, m, t] <- getIntList as <- getIntVec n let inf = 10^9 :: Int arr <- IO.newArray ((1,1),(n,n)) inf :: IO (IO.IOUArray (Int, Int) Int) forM_ [1..n] $ \i -> IO.writeArray arr (i,i) 0 replicateM m $ do [a, b, c] <- getIntList IO.writeArray arr (a, b) c arr' <- IO.freeze arr :: IO (A.UArray (Int, Int) Int) let costs = warshallFloyd arr' solve i r | i > n = r | otherwise = let waste = costs A.! (1, i) + costs A.! (i, 1) rest = max 0 (t - waste) gain = rest * as V.! (i-1) in solve (i+1) (max r gain) print $ solve 1 0
Submission Info
Submission Time | |
---|---|
Task | D - トレジャーハント |
User | unnohideyuki |
Language | Haskell (GHC 7.10.3) |
Score | 50 |
Code Size | 2449 Byte |
Status | RE |
Exec Time | 3162 ms |
Memory | 2065788 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 50 / 50 | 0 / 50 | ||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
Subtask1 | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 50_small_01.txt, 50_small_02.txt, 50_small_03.txt, 50_small_04.txt, 50_small_05.txt, 50_small_06.txt, 50_small_07.txt, 50_small_08.txt, 50_small_09.txt, 50_small_10.txt, 60_hand_01.txt, 60_hand_02.txt, 60_hand_03.txt, 60_hand_04.txt, 70_max_01.txt, 70_max_02.txt, 70_max_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 10_rand_09.txt, 10_rand_10.txt, 10_rand_12.txt, 10_rand_13.txt, 30_max_01.txt, 30_max_02.txt, 30_max_03.txt, 30_max_04.txt, 30_max_05.txt, 30_max_06.txt, 40_corner_01.txt, 40_corner_02.txt, 40_corner_03.txt, 40_corner_04.txt, 50_small_01.txt, 50_small_02.txt, 50_small_03.txt, 50_small_04.txt, 50_small_05.txt, 50_small_06.txt, 50_small_07.txt, 50_small_08.txt, 50_small_09.txt, 50_small_10.txt, 60_hand_01.txt, 60_hand_02.txt, 60_hand_03.txt, 60_hand_04.txt, 70_max_01.txt, 70_max_02.txt, 70_max_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 1 ms | 380 KB |
00_example_02.txt | AC | 1 ms | 380 KB |
00_example_03.txt | AC | 1 ms | 508 KB |
10_rand_01.txt | MLE | 658 ms | 2061308 KB |
10_rand_02.txt | RE | 794 ms | -1806980 KB |
10_rand_03.txt | RE | 1016 ms | -1382916 KB |
10_rand_04.txt | TLE | 3159 ms | 1301756 KB |
10_rand_05.txt | RE | 2 ms | 636 KB |
10_rand_06.txt | RE | 2 ms | 764 KB |
10_rand_07.txt | RE | 2 ms | 892 KB |
10_rand_08.txt | RE | 2 ms | 636 KB |
10_rand_09.txt | RE | 2 ms | 764 KB |
10_rand_10.txt | TLE | 3162 ms | -1991556 KB |
10_rand_12.txt | RE | 1038 ms | -1546372 KB |
10_rand_13.txt | MLE | 638 ms | 1933820 KB |
30_max_01.txt | MLE | 716 ms | 2065788 KB |
30_max_02.txt | RE | 2 ms | 764 KB |
30_max_03.txt | TLE | 3158 ms | 764284 KB |
30_max_04.txt | RE | 2 ms | 1276 KB |
30_max_05.txt | RE | 2 ms | 1276 KB |
30_max_06.txt | RE | 2 ms | 1276 KB |
40_corner_01.txt | RE | 2 ms | 764 KB |
40_corner_02.txt | RE | 2 ms | 764 KB |
40_corner_03.txt | RE | 2 ms | 764 KB |
40_corner_04.txt | RE | 2 ms | 764 KB |
50_small_01.txt | AC | 3 ms | 1020 KB |
50_small_02.txt | AC | 2 ms | 508 KB |
50_small_03.txt | AC | 15 ms | 1148 KB |
50_small_04.txt | AC | 2 ms | 1020 KB |
50_small_05.txt | AC | 6 ms | 1148 KB |
50_small_06.txt | AC | 4 ms | 1020 KB |
50_small_07.txt | AC | 14 ms | 1148 KB |
50_small_08.txt | AC | 2 ms | 508 KB |
50_small_09.txt | AC | 3 ms | 1020 KB |
50_small_10.txt | AC | 2 ms | 892 KB |
60_hand_01.txt | AC | 2 ms | 508 KB |
60_hand_02.txt | AC | 1 ms | 508 KB |
60_hand_03.txt | AC | 1 ms | 508 KB |
60_hand_04.txt | AC | 2 ms | 380 KB |
70_max_01.txt | AC | 110 ms | 3324 KB |
70_max_02.txt | AC | 110 ms | 3324 KB |
70_max_03.txt | AC | 110 ms | 3324 KB |