結果
問題 | No.40 多項式の割り算 |
ユーザー |
|
提出日時 | 2021-08-21 13:50:14 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 2,174 bytes |
コンパイル時間 | 8,471 ms |
コンパイル使用メモリ | 215,168 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 05:04:22 |
合計ジャッジ時間 | 3,948 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
コンパイルメッセージ
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.MonadwhenimportControl.Monad.StateStateT(..)importqualifiedData.ByteString.CharasBSCimportData.CharisSpaceimportData.CoercecoerceimportqualifiedData.ListasLimportqualifiedData.Vector.Fusion.Stream.MonadicasVFSMimportqualifiedData.Vector.UnboxedasVUimportqualifiedData.Vector.Unboxed.MutableasVUMmain::IO()main = dod <- readLn :: IO Intxs <- seqInput (d + 1)a <- VU.unsafeThaw xsrev' (d - 3) $ \i -> doai3 <- VUM.unsafeRead a (i + 3)VUM.unsafeModify a (+ ai3) (i + 1)VUM.unsafeWrite a (i + 3) 0b <- VUM.unsafeNew 1 :: IO (VUM.IOVector Int)rep' d $ \i -> doai <- VUM.unsafeRead a iwhen (ai /= 0) $ VUM.unsafeWrite b 0 in <- VUM.unsafeRead b 0print nVU.unsafeFreeze a >>= putStrLn . L.unwords . L.map show . VU.toList . VU.take (n + 1)return ()type Parser a = StateT BSC8.ByteString Maybe arunParser::Parsera->BSC8ByteString->MaybeaBSC8ByteStringrunParser = runStateTINLINEint::ParserIntint = coerce $ BSC8.readInt . BSC8.dropWhile isSpaceINLINEseqInput::Int->IOVUVectorIntseqInput n = VU.unfoldrN n (runParser int) <$> BSC8.getLineINLINErep'::Monadm=>Int->Int->m()->m()rep' n = flip VFSM.mapM_ (stream 0 (n + 1))INLINEstream::Monadm=>Int->Int->VFSMStreammIntstream !l !r = VFSM.Stream step lwherestep x| x < r = return $ VFSM.Yield x (x + 1)| otherwise = return VFSM.DoneINLINEINLINErev'::Monadm=>Int->Int->m()->m()rev' n = flip VFSM.mapM_ (streamR 0 (n + 1))INLINEstreamR::Monadm=>Int->Int->VFSMStreammIntstreamR !l !r = VFSM.Stream step (r - 1)wherestep x| x >= l = return $ VFSM.Yield x (x - 1)| otherwise = return VFSM.DoneINLINEINLINE