結果

問題 No.1032 数数え
ユーザー こまるこまる
提出日時 2020-11-20 23:50:21
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 1,122 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 232,920 KB
実行使用メモリ 15,812 KB
最終ジャッジ日時 2023-09-30 20:12:28
合計ジャッジ時間 3,422 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
7,764 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 3 ms
7,672 KB
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Monad.State
import           Data.Char
import           Data.Coerce
import           System.IO
import qualified Data.ByteString.Builder as BSB
import qualified Data.ByteString.Char8   as BSC8
import qualified Data.Vector.Unboxed     as VU

main :: IO ()
main = do
  [n, m] <- map (read :: String -> Int) . words <$> getLine
  ls <- seqInput n
  let xs = VU.tail . VU.indexed . VU.unsafeAccumulate (+) (VU.replicate (m + 1) 0) . VU.map (, 1 :: Int) $ ls
  VU.forM_ xs $ \(a, b) -> putBuilder $ BSB.intDec a <> BSB.byteString " " <> BSB.intDec b

type CParser a = StateT BSC8.ByteString Maybe a
runCParser :: CParser a -> BSC8.ByteString -> Maybe (a, BSC8.ByteString)
runCParser = runStateT
{-# INLINE runCParser #-}
int :: CParser Int
int = coerce $ BSC8.readInt . BSC8.dropWhile isSpace
{-# INLINE int #-}
seqInput :: Int -> IO (VU.Vector Int)
seqInput n = VU.unfoldrN n (runCParser int) <$> BSC8.getLine
{-# INLINE seqInput #-}

putBuilder :: BSB.Builder -> IO ()
putBuilder = BSB.hPutBuilder stdout
{-# INLINE putBuilder #-}
0