Submission #46444563
Source Code Expand
Copy
importqualifiedData.ByteString.CharasBSimportData.CharimportData.ListimportData.Arraymain::IO()main = do[n,x] <- bsGetLnIntsts <- bsGetLnIntslet ans = abc323e n x tsprint ansbsGetLnInts::IOIntbsGetLnInts = BS.getLine >>= return . unfoldr (BS.readInt . BS.dropWhile isSpace)abc323e::Int->Int->Int->Intabc323e n x ts@(t1:_) = answhere-- 1/n のmodPrecipN = modRecip n
import qualified Data.ByteString.Char8 as BS import Data.Char import Data.List import Data.Array main :: IO () main = do [n,x] <- bsGetLnInts ts <- bsGetLnInts let ans = abc323e n x ts print ans bsGetLnInts :: IO [Int] bsGetLnInts = BS.getLine >>= return . unfoldr (BS.readInt . BS.dropWhile isSpace) abc323e :: Int -> Int -> [Int] -> Int abc323e n x ts@(t1:_) = ans where -- 1/n のmodP recipN = modRecip n -- 時刻0~Xが、新たな曲を選択して始めるタイミングになっている確率 pa = listArray (0,x) $ map paf [0..x] paf 0 = 1 paf t = mul recipN $ summ [pa ! t1 | t1 <- takeWhile (0 <=) $ map (t -) sts] sts = sort ts -- 時刻 X-T1+1~X の確率に、T1が選択される確率1/Nを掛けた総和が答え ans = mul recipN $ reg $ summ $ drop (x - t1 + 1) $ elems pa -- mod modBase :: Int modBase = 998244353 reg :: Int -> Int reg x = mod x modBase add, mul :: Int -> Int -> Int add x y = reg $ x + y mul x y = reg $ x * y summ :: [Int] -> Int summ = foldl' add 0 -- @gotoki_no_joe modRecip a = powerish mul 1 a (modBase - 2) powerish mul i a b = foldl' {-'-} mul i [p | (True, p) <- zip bs ps] where bs = map odd $ takeWhile (0 <) $ iterate (flip div 2) b ps = iterate (\x -> mul x x) a
Submission Info
Submission Time | |
---|---|
Task | E - Playlist |
User | joetheshootingst |
Language | Haskell (GHC 9.4.5) |
Score | 450 |
Code Size | 1314 Byte |
Status | AC |
Exec Time | 111 ms |
Memory | 9980 KB |
Compile Error
app/Main.hs:18:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘abc323e’: Patterns of type ‘Int’, ‘Int’, ‘[Int]’ not matched: _ _ [] | 18 | abc323e n x ts@(t1:_) = ans | ^^^^^^^^^^^^^^^^^^^^^^^^^^^... app/Main.hs:25:42: warning: [-Wname-shadowing] This binding for ‘t1’ shadows the existing binding bound at app/Main.hs:18:17 | 25 | paf t = mul recipN $ summ [pa ! t1 | t1 <- takeWhile (0 <=) $ map (t -) sts] | ^^ app/Main.hs:42:1: warning: [-Wmissing-signatures] Top-level binding with no type signature: modRecip :: Int -> Int | 42 | modRecip a = powerish mul 1 a (modBase - 2) | ^^^^^^^^ app/Main.hs:43:1: warning: [-Wmissing-signatures] Top-level binding with no type signature: powerish :: Integral p => (b -> b -> b) -> b -> b -> p -> b | 43 | powerish mul i a b = foldl' {-'-} mul i [p | (True, p) <- zip bs ps] | ^^^^^^^^ app/Main.hs:43:10: warning: [-Wname-shadowing] This binding for ‘mul’ shadows the existing binding defined at app/Main.hs:37:1 | 43 | powerish mul i a b = foldl' {-'-} mul i [p | (True, p) <- zip bs ps] | ^^^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 450 / 450 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_00.txt, example_01.txt, example_02.txt |
All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_00.txt | AC | 2 ms | 6880 KB |
example_01.txt | AC | 2 ms | 6728 KB |
example_02.txt | AC | 3 ms | 9184 KB |
hand_00.txt | AC | 61 ms | 9300 KB |
hand_01.txt | AC | 101 ms | 9980 KB |
hand_02.txt | AC | 7 ms | 8984 KB |
hand_03.txt | AC | 91 ms | 9864 KB |
hand_04.txt | AC | 3 ms | 9308 KB |
hand_05.txt | AC | 3 ms | 8924 KB |
hand_06.txt | AC | 2 ms | 6680 KB |
random_00.txt | AC | 2 ms | 6676 KB |
random_01.txt | AC | 101 ms | 9868 KB |
random_02.txt | AC | 101 ms | 9936 KB |
random_03.txt | AC | 101 ms | 9884 KB |
random_04.txt | AC | 101 ms | 9924 KB |
random_05.txt | AC | 101 ms | 9864 KB |
random_06.txt | AC | 111 ms | 9844 KB |
random_07.txt | AC | 101 ms | 9040 KB |
random_08.txt | AC | 111 ms | 9908 KB |
random_09.txt | AC | 101 ms | 9468 KB |
random_10.txt | AC | 1 ms | 6752 KB |
random_11.txt | AC | 101 ms | 9008 KB |
random_12.txt | AC | 101 ms | 9840 KB |
random_13.txt | AC | 101 ms | 9072 KB |
random_14.txt | AC | 91 ms | 9076 KB |
random_15.txt | AC | 61 ms | 8832 KB |
random_16.txt | AC | 61 ms | 9056 KB |
random_17.txt | AC | 61 ms | 9256 KB |
random_18.txt | AC | 61 ms | 9152 KB |
random_19.txt | AC | 61 ms | 9828 KB |