提出 #69674798
ソースコード 拡げる
{-# OPTIONS_GHC -Wall #-} {-# OPTIONS_GHC -Wname-shadowing #-} -- 内側のスコープの値と同じ名前が外側のスコープにあるとき警告する import Control.Monad import qualified Data.ByteString.Char8 as BS import Data.Char import Data.List import qualified Data.Array.Unboxed as AU readInts :: IO [Int] readInts = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine main :: IO () main = do [n,q] <- readInts as <- readInts qs <- replicateM q readInts let ss = scanl (+) 0 $ as ++ as -- 2周分用意する let arr = AU.listArray (0,2*n) ss :: AU.UArray Int Int -- print arr putStr $ unlines $ map show $ solve n 0 arr qs solve n idx arr [] = [] solve n idx arr (q:qs) = case q of (1:c:_) -> solve n ((idx+c)`mod`n) arr qs (2:l:r:_) -> arr AU.! r2 - arr AU.! (l2-1) : solve n idx arr qs where l1 = (l + idx)`mod`n r1 = (r + idx)`mod`n l2 = if l1 < idx then l1 + n else l1 r2 = if r1 < idx || r1 < l2 then r1 + n else r1
提出情報
提出日時 | |
---|---|
問題 | C - Rotate and Sum Query |
ユーザ | haskboy |
言語 | Haskell (GHC 9.4.5) |
得点 | 0 |
コード長 | 1128 Byte |
結果 | RE |
実行時間 | 213 ms |
メモリ | 87420 KiB |
コンパイルエラー
app/Main.hs:23:1: warning: [-Wmissing-signatures] Top-level binding with no type signature: solve :: (AU.IArray a1 a2, AU.Ix i, Integral i, Num a2) => i -> i -> a1 i a2 -> [[i]] -> [a2] | 23 | solve n idx arr [] = [] | ^^^^^ app/Main.hs:23:7: warning: [-Wunused-matches] Defined but not used: ‘n’ | 23 | solve n idx arr [] = [] | ^ app/Main.hs:23:9: warning: [-Wunused-matches] Defined but not used: ‘idx’ | 23 | solve n idx arr [] = [] | ^^^ app/Main.hs:23:13: warning: [-Wunused-matches] Defined but not used: ‘arr’ | 23 | solve n idx arr [] = [] | ^^^ app/Main.hs:24:26: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In a case alternative: Patterns of type ‘[i]’ not matched: [] (p:_) where p is not one of {1, 2} [1] [2] ... | 24 | solve n idx arr (q:qs) = case q of | ^^^^^^^^^...
ジャッジ結果
セット名 | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
得点 / 配点 | 0 / 0 | 0 / 350 | ||||||
結果 |
|
|
セット名 | テストケース |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt |
ケース名 | 結果 | 実行時間 | メモリ |
---|---|---|---|
00_sample_00.txt | AC | 2 ms | 6856 KiB |
00_sample_01.txt | AC | 2 ms | 6856 KiB |
01_random_00.txt | RE | 2 ms | 6748 KiB |
01_random_01.txt | RE | 62 ms | 42568 KiB |
01_random_02.txt | AC | 143 ms | 72268 KiB |
01_random_03.txt | AC | 41 ms | 30936 KiB |
01_random_04.txt | AC | 143 ms | 66944 KiB |
01_random_05.txt | AC | 173 ms | 83644 KiB |
01_random_06.txt | AC | 133 ms | 61984 KiB |
01_random_07.txt | AC | 183 ms | 83580 KiB |
01_random_08.txt | AC | 173 ms | 87420 KiB |
01_random_09.txt | AC | 183 ms | 83580 KiB |
01_random_10.txt | AC | 173 ms | 86308 KiB |
01_random_11.txt | AC | 173 ms | 83508 KiB |
01_random_12.txt | AC | 143 ms | 77252 KiB |
01_random_13.txt | AC | 143 ms | 77188 KiB |
01_random_14.txt | AC | 213 ms | 84628 KiB |
01_random_15.txt | AC | 213 ms | 85588 KiB |
01_random_16.txt | AC | 204 ms | 84668 KiB |
01_random_17.txt | AC | 143 ms | 80496 KiB |
01_random_18.txt | AC | 184 ms | 79516 KiB |
01_random_19.txt | AC | 153 ms | 78472 KiB |