結果
問題 | No.1219 Mancala Combo |
ユーザー |
![]() |
提出日時 | 2020-09-25 13:23:44 |
言語 | Haskell (9.10.1) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 12,718 bytes |
コンパイル時間 | 299 ms |
コンパイル使用メモリ | 168,704 KB |
最終ジャッジ日時 | 2024-11-14 23:50:26 |
合計ジャッジ時間 | 1,330 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
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:52:1: error: [GHC-87110] Could not load module ‘GHC.Integer.GMP.Internals’. It is a member of the hidden package ‘integer-gmp-1.1’. Use -v to see a list of the files searched for. | 52 | import qualified GHC.Integer.GMP.Internals as GMP | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Main.hs:53:1: error: [GHC-87110] Could not find module ‘GHC.Integer.Logarithms.Internals’. Use -v to see a list of the files searched for. | 53 | import qualified GHC.Integer.Logarithms.Internals as Log | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
LANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGE{- base -}importControl.ArrowimportControl.MonadimportControl.Monad.STimportData.BitsimportData.BoolimportData.CharimportData.CoerceimportData.FunctionimportData.Functor.IdentityimportData.IORefimportData.IximportData.MonoidimportData.OrdimportData.RatioimportData.SemigroupimportData.STRefimportData.VoidimportData.WordimportGHC.ExtsimportUnsafe.Coerce{- array -}importqualifiedData.ArrayasArrimportqualifiedData.Array.IOasArrIOimportqualifiedData.Array.MArrayasArrMAimportqualifiedData.Array.STasArrSTimportqualifiedData.Array.UnboxedasArrU{- bytestring -}importqualifiedData.ByteStringasBSimportqualifiedData.ByteString.BuilderasBSBimportqualifiedData.ByteString.Builder.ExtraasBSBEimportqualifiedData.ByteString.Builder.PrimasBSBPimportqualifiedData.ByteString.CharasBSCimportqualifiedData.ByteString.LazyasBSLimportqualifiedData.ByteString.Lazy.CharasBSLCimportqualifiedData.ByteString.ShortasBSSimportqualifiedData.ByteString.UnsafeasBSU{- integer-gmp -}importqualifiedGHC.Integer.GMP.InternalsasGMPimportqualifiedGHC.Integer.Logarithms.InternalsasLog{- vector -}importqualifiedData.VectorasVimportqualifiedData.Vector.Fusion.Stream.MonadicasVFSMimportqualifiedData.Vector.GenericasVGimportqualifiedData.Vector.Generic.MutableasVGMimportqualifiedData.Vector.MutableasVMimportqualifiedData.Vector.PrimitiveasVPimportqualifiedData.Vector.Primitive.MutableasVPMimportqualifiedData.Vector.StorableasVSimportqualifiedData.Vector.Storable.MutableasVSMimportqualifiedData.Vector.UnboxedasVUimportqualifiedData.Vector.Unboxed.MutableasVUM-------------------------------------------------------------------------------# MOD 1000000007# Fact_CACHE_SIZE 100100# LOG_FACT_CACHE_SIZE 1024-------------------------------------------------------------------------------fi::Int->Integerfi = fromIntegralINLINEfI::Integer->IntfI = fromIntegerINLINEfloorSqrt::Int->IntfloorSqrt = floor . sqrt . fromIntegralINLINEfloorLog2::Int->IntfloorLog2 x = fromIntegral $ unsafeShiftR y 52 - 1023wherey::Word64y = unsafeCoerce (fromIntegral x :: Double)INLINEpowModInt::Int->Int->Int->IntpowModInt a b c = fI $ GMP.powModInteger (fi a) (fi b) (fi c)INLINErecipModInt::Int->Int->IntrecipModInt a m = fI $ GMP.recipModInteger (fi a) (fi m)INLINEgcdext::Int->Int->IntIntInt-- a * x + b * y = d => (x, y, d) (d = gcd a b)gcdext a b = (x, y, d)whered = gcd a b(x, y) = case GMP.gcdExtInteger (fi a) (fi b) of(# p, q #) -> (fI p, fI q)INLINEmodInv::Int->Int->IntmodInv a mo| 1 == g = mkPos i| otherwise = -1where(i, _, g) = gcdext a momkPos x| x < 0 = x + mo| otherwise = xINLINEstream::Monadm=>Int->Int->VFSMStreammIntstream !l !r = VFSM.Stream step lwherestep x| x < r = return $ VFSM.Yield x (x + 1)| otherwise = return $ VFSM.DoneINLINEINLINErep::Monadm=>Int->Int->m()->m()rep n = flip VFSM.mapM_ (stream 0 n)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.DoneINLINEINLINErev::Monadm=>Int->Int->m()->m()rev !n = flip VFSM.mapM_ (streamR 0 n)INLINEstreamStep::Monadm=>Int->Int->Int->VFSMStreammIntstreamStep !l !r !d = VFSM.Stream step lwherestep x| x < r = return $ VFSM.Yield x (x + d)| otherwise = return VFSM.DoneINLINEINLINEinfixl 8 `shiftRL`, `unsafeShiftRL`shiftRL::Int->Int->IntshiftRL = unsafeShiftRLINLINEunsafeShiftRL::Int->Int->IntunsafeShiftRL (I# x#) (I# i#) = I# (uncheckedIShiftRL# x# i#)INLINElowerBoundM::Monadm=>Int->Int->Int->mBool->mIntlowerBoundM low high p = go low highwherego !low !high| high <= low = return high| otherwise = p mid >>= bool (go (mid + 1) high) (go low mid)wheremid = low + unsafeShiftRL (high - low) 1INLINEupperBoundM::Monadm=>Int->Int->Int->mBool->mIntupperBoundM low high p = doflg <- p highif flgthen return highelse subtract 1 <$!> lowerBoundM low high (fmap not.p)INLINElowerBound::Int->Int->Int->Bool->IntlowerBound low high p = runIdentity (lowerBoundM low high (return . p))INLINEupperBound::Int->Int->Int->Bool->IntupperBound low high p = runIdentity (upperBoundM low high (return . p))INLINE(.>>.)::Bitsi=>i->Int->i(.>>.) = unsafeShiftRINLINE(.<<.)::Bitsi=>i->Int->i(.<<.) = unsafeShiftLINLINE(.>>>.)::Int->Int->Int(.>>>.) = unsafeShiftRLINLINE-------------------------------------------------------------------------------type Parser a = BSC8.ByteString -> Maybe (a, BSC8.ByteString)parseInt::ParserIntparseInt = fmap (second BSC8.tail) . BSC8.readIntparseChar::Char->VUVectorCharparseChar = VU.fromListparse1::IOIntparse1 = readLnparse2::IOIntIntparse2 = (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 parseInt <$> BSC8.getLineparse3::IOIntIntIntparse3 = (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2)) . VU.unfoldrN 3 parseInt <$> BSC8.getLineparse4::IOIntIntIntIntparse4 = (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2, vec VU.! 3)) . VU.unfoldrN 4 parseInt <$> BSC8.getLineparseM::Int->IOVUVectorIntparseM m = VU.unfoldrN m parseInt <$> BSC8.getLineparseN::Int->IOVUVectorIntparseN n = VU.replicateM n parse1parseNM::Int->Int->IOVVectorVUVectorIntparseNM n m = V.replicateM n $ VU.unfoldrN m parseInt <$> BSC8.getLineparseANBN::Int->IOVUVectorIntVUVectorIntparseANBN n = dovectup <- VU.replicateM n $ (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLinereturn $ VU.unzip vectupparseANBNCN::Int->IOVUVectorIntVUVectorIntVUVectorIntparseANBNCN n = dovectup <- VU.replicateM n $ (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2)) . VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLinereturn $ VU.unzip3 vectup-------------------------------------------------------------------------------modulus::Numa=>amodulus = MODINLINEinfixr 8 ^%infixl 7 *%, /%infixl 6 +%, -%(+%)::Int->Int->Int(+%) (I# x#) (I# y#) = case x# +# y# ofr# -> I# (r# -# ((r# >=# MOD#) *# MOD#))INLINE(-%)::Int->Int->Int(-%) (I# x#) (I# y#) = case x# -# y# ofr# -> I# (r# +# ((r# <# 0#) *# MOD#))INLINE(*%) :: Int -> Int -> Int(*%) (I# x#) (I# y#) = case timesWord# (int2Word# x#) (int2Word# y#) ofz# -> case timesWord2# z# im# of(# q#, _ #) -> case minusWord# z# (timesWord# q# m#) ofv# | isTrue# (geWord# v# m#) -> I# (word2Int# (plusWord# v# m#))| otherwise -> I# (word2Int# v#)wherem# = int2Word# MOD#im# = plusWord# (quotWord# 0xffffffffffffffff## m#) 1##INLINE(/%)::Int->Int->Int(/%) (I# x#) (I# y#) = go# y# MOD# 1# 0#wherego# a# b# u# v#| isTrue# (b# ># 0#) = case a# `quotInt#` b# ofq# -> go# b# (a# -# (q# *# b#)) v# (u# -# (q# *# v#))| otherwise = I# ((x# *# (u# +# MOD#)) `remInt#` MOD#)INLINE(^%) :: Int -> Int -> Int(^%) x n| n > 0 = go 1 x n| n == 0 = 1| otherwise = go 1 (1 /% x) (-n)wherego !acc !y !m| m .&. 1 == 0 = go acc (y *% y) (unsafeShiftR m 1)| m == 1 = acc *% y| otherwise = go (acc *% y) (y *% y) (unsafeShiftR (m - 1) 1)newtype Mint = Mint { getMint :: Int }deriving newtype (Eq, Ord, Read, Show, Real)mint::Integrala=>a->Mintmint x = fromIntegral $ mod (fromIntegral x) MODINLINEinstanceNumMintwhere(+) = coerce (+%)(-) = coerce (-%)(*) = coerce (*%)abs = idsignum = const (Mint 1)fromInteger x = coerce @Int @Mint . fromInteger $ mod x modulusinstanceBoundedMintwhereminBound = Mint 0maxBound = Mint $ modulus - 1instanceEnumMintwheretoEnum = mintfromEnum = coerceinstanceIntegralMintwherequotRem x y = (x / y, x - x / y * y)toInteger = coerce (toInteger @Int)instanceFractionalMintwhere(/) = coerce (/%)fromRational q = fromInteger (numerator q) / fromInteger (denominator q)newtype instanceVUVectorMintV_MintVUVectorIntnewtype instanceVUMMVectorsMintMV_MintVUMMVectorsIntinstanceVUUnboxMintinstanceVGMMVectorVUMMVectorMintwherebasicLength (MV_Mint v) = VGM.basicLength vINLINEbasicUnsafeSlice i n (MV_Mint v) = MV_Mint $ VGM.basicUnsafeSlice i n vINLINEbasicOverlaps (MV_Mint v1) (MV_Mint v2) = VGM.basicOverlaps v1 v2INLINEbasicUnsafeNew n = MV_Mint `fmap` VGM.basicUnsafeNew nINLINEbasicInitialize (MV_Mint v) = VGM.basicInitialize vINLINEbasicUnsafeReplicate n x = MV_Mint `fmap` VGM.basicUnsafeReplicate n (coerce x)INLINEbasicUnsafeRead (MV_Mint v) i = coerce `fmap` VGM.basicUnsafeRead v iINLINEbasicUnsafeWrite (MV_Mint v) i x = VGM.basicUnsafeWrite v i (coerce x)INLINEbasicClear (MV_Mint v) = VGM.basicClear vINLINEbasicSet (MV_Mint v) x = VGM.basicSet v (coerce x)INLINEbasicUnsafeCopy (MV_Mint v1) (MV_Mint v2) = VGM.basicUnsafeCopy v1 v2INLINEbasicUnsafeMove (MV_Mint v1) (MV_Mint v2) = VGM.basicUnsafeMove v1 v2INLINEbasicUnsafeGrow (MV_Mint v) n = MV_Mint `fmap` VGM.basicUnsafeGrow v nINLINEinstanceVGVectorVUVectorMintwherebasicUnsafeFreeze (MV_Mint v) = V_Mint `fmap` VG.basicUnsafeFreeze vINLINEbasicUnsafeThaw (V_Mint v) = MV_Mint `fmap` VG.basicUnsafeThaw vINLINEbasicLength (V_Mint v) = VG.basicLength vINLINEbasicUnsafeSlice i n (V_Mint v) = V_Mint $ VG.basicUnsafeSlice i n vINLINEbasicUnsafeIndexM (V_Mint v) i = coerce `fmap` VG.basicUnsafeIndexM v iINLINEbasicUnsafeCopy (MV_Mint mv) (V_Mint v) = VG.basicUnsafeCopy mv velemseq _ = seqINLINE-------------------------------------------------------------------------------main::IO()main = dom <- parse1as <- parseM mlet sumA = VU.sum aslet bs = VU.scanl1 (+) asputStrLn $ bool "No" "Yes" $ VU.and $ VU.imap (\i a -> if i == 0 then True else 0 == mod (sumA - bs VU.! (i - 1)) (i + 1)) bs