結果
問題 | No.1220 yukipoker |
ユーザー |
|
提出日時 | 2020-10-22 12:48:22 |
言語 | Haskell (9.10.1) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 13,791 bytes |
コンパイル時間 | 469 ms |
コンパイル使用メモリ | 153,728 KB |
最終ジャッジ日時 | 2024-07-21 09:16:03 |
合計ジャッジ時間 | 1,404 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:28: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. | 28 | import qualified GHC.Integer.GMP.Internals as GMP | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
LANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGELANGUAGEimportControl.MonadimportControl.Monad.StateimportData.BitsimportData.BoolimportData.CharimportData.CoerceimportData.Functor.IdentityimportData.RatioimportData.WordimportGHC.ExtsimportUnsafe.CoerceimportqualifiedData.ByteStringasBSimportqualifiedData.ByteString.CharasBSCimportqualifiedGHC.Integer.GMP.InternalsasGMPimportqualifiedData.Vector.Fusion.Stream.MonadicasVFSMimportqualifiedData.Vector.GenericasVGimportqualifiedData.Vector.Generic.MutableasVGMimportqualifiedData.Vector.UnboxedasVUimportqualifiedData.Vector.Unboxed.MutableasVUM-------------------------------------------------------------------------------# MOD 1000000007# Fact_CACHE_SIZE 100100# LOG_FACT_CACHE_SIZE 100100-------------------------------------------------------------------------------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--------------------------------------------------------------------------------- Input-------------------------------------------------------------------------------type CParser a = StateT BSC8.ByteString Maybe arunCParser::CParsera->BSC8ByteString->MaybeaBSC8ByteStringrunCParser = runStateTINLINEint::CParserIntint = coerce $ BSC8.readInt . BSC8.dropWhile isSpaceINLINEint1::CParserIntint1 = fmap (subtract 1) intINLINEchar::CParserCharchar = coerce BSC8.unconsINLINEbyte::CParserWord8byte = coerce BS.unconsINLINEskipSpaces::CParser()skipSpaces = modify' (BSC8.dropWhile isSpace)INLINEseqInput::Int->IOVUVectorIntseqInput n = VU.unfoldrN n (runCParser int) <$> BSC8.getLineINLINEparseN2::Int->IOVUVectorIntIntparseN2 n = VU.unfoldrN n (runCParser $ (,) <$> int <*> int) <$> BSC8.getContentsINLINEparseN3::Int->IOVUVectorIntIntIntparseN3 n = VU.unfoldrN n (runCParser $ (,,) <$> int <*> int <*> int) <$> BSC8.getContentsINLINEparseN4::Int->IOVUVectorIntIntIntIntparseN4 n = VU.unfoldrN n (runCParser $ (,,,) <$> int <*> int <*> int <*> int) <$> BSC8.getContentsINLINEparseN5::Int->IOVUVectorIntIntIntIntIntparseN5 n = VU.unfoldrN n (runCParser $ (,,,,) <$> int <*> int <*> int <*> int <*> int) <$> BSC8.getContentsINLINEparseANBN::Int->IOVUVectorIntVUVectorIntparseANBN n = VU.unzip . VU.unfoldrN n (runCParser $ (,) <$> int <*> int) <$> BSC8.getContentsINLINEparseANBNCN::Int->IOVUVectorIntVUVectorIntVUVectorIntparseANBNCN n = VU.unzip3 . VU.unfoldrN n (runCParser $ (,,) <$> int <*> int <*> int) <$> BSC8.getContentsINLINEtype Query5 = (Int, Int, Int, Int, Int)query5Parser::CParserQuery5query5Parser = doskipSpacest <- charcase t of'0' -> (,,,,) 0 <$> int <*> int <*> int <*> int_ -> (,,,,) 1 <$> int <*> int <*> pure 0 <*> pure 0parseQ5::Int->IOVUVectorQuery5parseQ5 n = VU.unfoldrN n (runCParser query5Parser) <$> BSC8.getContentsINLINE-------------------------------------------------------------------------------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-------------------------------------------------------------------------------fact::Int->Mintfact = VU.unsafeIndex factCacheINLINErecipFact::Int->MintrecipFact = VU.unsafeIndex recipFactCacheINLINEnPk::Int->Int->MintnPk n k = fact n * recipFact (n - k)INLINEnCk::Int->Int->MintnCk n k = fact n * recipFact (n - k) * recipFact kINLINE_factCacheSize::Int_factCacheSize = Fact_CACHE_SIZEfactCacheSize::IntfactCacheSize = min (modulus - 1) _factCacheSizeINLINEfactCache::VUVectorMintfactCache = VU.scanl' (\x y -> x * coerce y) (1 :: Mint) $ VU.generate factCacheSize (+1)recipFactCache::VUVectorMintrecipFactCache = VU.scanr' ((*).coerce) (1 / factCache VU.! factCacheSize)$ VU.generate factCacheSize (+1)-------------------------------------------------------------------------------logFactCacheSize::IntlogFactCacheSize = LOG_FACT_CACHE_SIZElogFactCache::VUVectorDoublelogFactCache = VU.scanl' (+) 0.0 $ VU.generate logFactCacheSize (log . fromIntegral . (+1))logFact::Int->DoublelogFact = VU.unsafeIndex logFactCacheINLINElognPk::Int->Int->DoublelognPk n k = logFact n - logFact (n - k)INLINElognCk::Int->Int->DoublelognCk n k = logFact n - logFact k - logFact (n - k)INLINE-------------------------------------------------------------------------------main::IO()main = doquery <- readLn :: IO Intqs <- parseN3 queryputStr . unlines . map (bool "Straight" "Flush") . VU.toList $ solver qssolver::VUVectorIntIntInt->VUVectorBoolsolver = VU.map (\(n, m, k) -> (log (fromIntegral m) + lognCk n k) < ((log (fromIntegral (n - k + 1))) + ((fromIntegral k) * log (fromIntegral m))))