結果
問題 | No.29 パワーアップ |
ユーザー |
|
提出日時 | 2020-12-07 20:29:32 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 4,904 bytes |
コンパイル時間 | 8,580 ms |
コンパイル使用メモリ | 177,048 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 14:02:56 |
合計ジャッジ時間 | 9,129 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
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
ソースコード
LANGUAGEimportControl.Monad.ContimportControl.Monad.STimportData.IORefimportqualifiedData.Vector.Fusion.Stream.MonadicasVFSMimportqualifiedData.Vector.Unboxed.MutableasVUMmain::IO()main = docnt <- VUM.replicate 20 0 :: IO (VUM.IOVector Int)n <- readLn :: IO Intrep n $ \_ -> do[a, b, c] <- map (read :: String -> Int) . words <$> getLineVUM.unsafeModify cnt succ aVUM.unsafeModify cnt succ bVUM.unsafeModify cnt succ cresRef <- newIORef (0 :: Int)restRef <- newIORef (0 :: Int)rep1' 10 $ \i -> docnti <- VUM.unsafeRead cnt imodifyIORef' resRef (+ (cnti `div` 2))modifyIORef' restRef (+ (cnti `mod` 2))rest <- readIORef restRefmodifyIORef' resRef (+ (rest `div` 4))print =<< readIORef resRef--------------------------------------------------------------------------------- for-------------------------------------------------------------------------------rep::Monadm=>Int->Int->m()->m()rep n = flip VFSM.mapM_ (stream 0 n)INLINErep'::Monadm=>Int->Int->m()->m()rep' n = flip VFSM.mapM_ (stream 0 (n + 1))INLINErep1::Monadm=>Int->Int->m()->m()rep1 n = flip VFSM.mapM_ (stream 1 n)INLINErep1'::Monadm=>Int->Int->m()->m()rep1' n = flip VFSM.mapM_ (stream 1 (n + 1))INLINErev::Monadm=>Int->Int->m()->m()rev n = flip VFSM.mapM_ (streamR 0 n)INLINErev'::Monadm=>Int->Int->m()->m()rev' n = flip VFSM.mapM_ (streamR 0 (n + 1))INLINErev1::Monadm=>Int->Int->m()->m()rev1 n = flip VFSM.mapM_ (streamR 1 n)INLINErev1'::Monadm=>Int->Int->m()->m()rev1' n = flip VFSM.mapM_ (streamR 1 (n + 1))INLINErange::Monadm=>Int->Int->Int->m()->m()range l r = flip VFSM.mapM_ (stream l (r + 1))INLINErangeR::Monadm=>Int->Int->Int->m()->m()rangeR r l = flip VFSM.mapM_ (streamR l (r + 1))INLINEforStep::Monadm=>Int->Int->Int->Int->m()->m()forStep l r d = flip VFSM.mapM_ (streamStep l r d)INLINEforStepR::Monadm=>Int->Int->Int->Int->m()->m()forStepR r l d = flip VFSM.mapM_ (streamStepR l r d)INLINEforP::Monadm=>Int->Int->m()->m()forP p = flip VFSM.mapM_ (streamG 2 p (^) 2 (+) 1)INLINEforG::Monadm=>Int->Int->Int->Int->Int->Int->Int->Int->Int->Int->Int->m()->m()forG l r f p g d = flip VFSM.mapM_ (streamG l r f p g d)INLINEforRG::Monadm=>Int->Int->Int->Int->Int->Int->Int->Int->Int->Int->Int->m()->m()forRG r l f p g d = flip VFSM.mapM_ (streamRG r l f p g d)INLINEstream::Monadm=>Int->Int->VFSMStreammIntstream !l !r = VFSM.Stream step lwherestep x| x < r = return $ VFSM.Yield x (x + 1)| otherwise = return VFSM.DoneINLINEINLINEstreamR::Monadm=>Int->Int->VFSMStreammIntstreamR !l !r = VFSM.Stream step (r - 1)wherestep x| x >= l = return $ VFSM.Yield x (x - 1)| otherwise = return VFSM.DoneINLINEINLINEstreamStep::Monadm=>Int->Int->Int->VFSMStreammIntstreamStep !l !r !d = VFSM.Stream step lwherestep x| x <= r = return $ VFSM.Yield x (x + d)| otherwise = return VFSM.DoneINLINEINLINEstreamStepR::Monadm=>Int->Int->Int->VFSMStreammIntstreamStepR !l !r !d = VFSM.Stream step rwherestep x| x >= l = return $ VFSM.Yield x (x - d)| otherwise = return VFSM.DoneINLINEINLINEstreamG::Monadm=>Int->Int->Int->Int->Int->Int->Int->Int->Int->Int->VFSMStreammIntstreamG !l !r !f !p !g !d = VFSM.Stream step lwherestep x| f x p <= r = return $ VFSM.Yield x (g x d)| otherwise = return VFSM.DoneINLINEINLINEstreamRG::Monadm=>Int->Int->Int->Int->Int->Int->Int->Int->Int->Int->VFSMStreammIntstreamRG !r !l !f !p !g !d = VFSM.Stream step rwherestep x| f x p >= l = return $ VFSM.Yield x (g x d)| otherwise = return VFSM.DoneINLINEINLINEwithBreakIO::r->ContTrIOb->ContTrIOr->IOrwithBreakIO = flip runContT pure . callCCINLINEwithBreakST::r->ContTrSTsb->ContTrSTsr->STsrwithBreakST = flip runContT pure . callCCINLINE