結果
問題 | No.1021 Children in Classrooms |
ユーザー | こまる |
提出日時 | 2020-11-08 04:01:45 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,010 bytes |
コンパイル時間 | 4,186 ms |
コンパイル使用メモリ | 224,256 KB |
実行使用メモリ | 20,876 KB |
最終ジャッジ日時 | 2024-07-22 15:00:32 |
合計ジャッジ時間 | 6,574 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 5 ms
7,680 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 90 ms
19,628 KB |
testcase_17 | WA | - |
testcase_18 | AC | 114 ms
20,876 KB |
testcase_19 | WA | - |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE BinaryLiterals #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DerivingVia #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE UnicodeSyntax #-} {-# LANGUAGE ViewPatterns #-} import Control.Monad import Control.Monad.Cont import Control.Monad.Fix import Control.Monad.ST import Control.Monad.State import Data.Bits import Data.Bool import Data.Char import Data.Coerce import qualified Data.Foldable as F import qualified Data.List as L import Data.IORef import Data.STRef import Data.Word import GHC.Exts import System.IO import Unsafe.Coerce import qualified Data.ByteString as BS import qualified Data.ByteString.Builder as BSB import qualified Data.ByteString.Char8 as BSC8 import qualified Data.ByteString.Unsafe as BSU import qualified Data.Vector as V import qualified Data.Vector.Fusion.Stream.Monadic as VFSM import qualified Data.Vector.Generic as VG import qualified Data.Vector.Generic.Mutable as VGM import qualified Data.Vector.Mutable as VM import qualified Data.Vector.Unboxed as VU import qualified Data.Vector.Unboxed.Mutable as VUM main :: IO () main = do [n, m] <- map (read @Int) . words <$> getLine ax <- seqInput' n sx <- seqInput m cnt <- VUM.replicate (n + 2 * m + 10) (0 :: Int) cur <- newIORef (m + 5) rep n $ \i -> VUM.unsafeWrite cnt (m + 5 + i) (ax VU.! i) rep m $ \i -> do cu <- readIORef cur if sx VU.! i == 'L' then do item <- VUM.unsafeRead cnt cu VUM.unsafeModify cnt (+ item) (cu + 1) modifyIORef' cur succ else do item <- VUM.unsafeRead cnt (cu + n - 1) VUM.unsafeModify cnt (+ item) (cu + n - 2) VUM.unsafeWrite cnt (cu + n - 1) 0 modifyIORef' cur pred rep n $ \i -> do when (i /= 0) $ putStr " " cu <- readIORef cur ans <- VUM.unsafeRead cnt (cu + i) putStr $ show ans putStr "\n" 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 #-} char :: CParser Char char = coerce BSC8.uncons {-# INLINE char #-} seqInput :: Int -> IO (VU.Vector Char) seqInput n = VU.unfoldrN n (runCParser char) <$> BSC8.getLine {-# INLINE seqInput #-} seqInput' :: Int -> IO (VU.Vector Int) seqInput' n = VU.unfoldrN n (runCParser int) <$> BSC8.getLine {-# INLINE seqInput' #-} stream :: Monad m => Int -> Int -> VFSM.Stream m Int stream !l !r = VFSM.Stream step l where step x | x < r = return $ VFSM.Yield x (x + 1) | otherwise = return $ VFSM.Done {-# INLINE [0] step #-} {-# INLINE [1] stream #-} rep :: Monad m => Int -> (Int -> m ()) -> m () rep n = flip VFSM.mapM_ (stream 0 n) {-# INLINE rep #-}