結果

問題 No.741 AscNumber(Easy)
ユーザー torus711torus711
提出日時 2018-10-13 14:54:47
言語 Haskell
(9.8.2)
結果
AC  
実行時間 796 ms / 2,000 ms
コード長 1,205 bytes
コンパイル時間 2,102 ms
コンパイル使用メモリ 177,280 KB
実行使用メモリ 89,856 KB
最終ジャッジ日時 2024-04-20 20:03:56
合計ジャッジ時間 13,694 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 753 ms
85,760 KB
testcase_36 AC 340 ms
39,552 KB
testcase_37 AC 386 ms
45,952 KB
testcase_38 AC 382 ms
45,312 KB
testcase_39 AC 327 ms
38,656 KB
testcase_40 AC 446 ms
51,328 KB
testcase_41 AC 709 ms
78,592 KB
testcase_42 AC 367 ms
43,264 KB
testcase_43 AC 266 ms
32,640 KB
testcase_44 AC 543 ms
62,208 KB
testcase_45 AC 593 ms
67,072 KB
testcase_46 AC 734 ms
81,920 KB
testcase_47 AC 126 ms
17,024 KB
testcase_48 AC 737 ms
81,920 KB
testcase_49 AC 611 ms
68,992 KB
testcase_50 AC 87 ms
12,544 KB
testcase_51 AC 284 ms
34,048 KB
testcase_52 AC 790 ms
89,728 KB
testcase_53 AC 792 ms
89,856 KB
testcase_54 AC 796 ms
88,832 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:37:1: warning: [GHC-94817] [-Wtabs]
    Tab character found here, and in 26 further locations.
    Suggested fix: Please use spaces instead.
   |
37 |         dp <- newArray ( ( 0, 0 ), ( n, 10 ) ) 0 :: ST s ( STUArray s ( Int, Int ) Int )
   | ^^^^^^^^
[2 of 2] Linking a.out

ソースコード

diff #

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInt >>= print . solve

m = 1000000007

solve n = runST $ do
	dp <- newArray ( ( 0, 0 ), ( n, 10 ) ) 0 :: ST s ( STUArray s ( Int, Int ) Int )
	writeArray dp ( 0, 0 ) 1
	forM_ [ 0 .. n - 1 ] $ \i -> do
		forM_ [ 0 .. 9 ] $ \j -> do
			cur <- readArray dp ( i, j )
			forM_ [ j .. 9 ] $ \k -> do
				tar <- readArray dp ( i + 1, k )
				writeArray dp ( i + 1, k ) ( ( cur + tar ) `mod` m	)
	res <- newSTRef 0
	forM_ [ 0 .. 9 ] $ \j -> do
		val <- readArray dp ( n, j )
		modifySTRef res ( ( `mod` m ) . ( + val ) )
	readSTRef res
0