結果
問題 | No.805 UMG |
ユーザー | iwot |
提出日時 | 2020-06-08 18:05:07 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,048 bytes |
コンパイル時間 | 9,404 ms |
コンパイル使用メモリ | 169,216 KB |
実行使用メモリ | 14,752 KB |
最終ジャッジ日時 | 2024-11-18 14:02:18 |
合計ジャッジ時間 | 22,741 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
12,068 KB |
testcase_01 | AC | 2 ms
14,632 KB |
testcase_02 | AC | 2 ms
12,068 KB |
testcase_03 | AC | 2 ms
14,752 KB |
testcase_04 | AC | 2 ms
12,068 KB |
testcase_05 | AC | 2 ms
12,928 KB |
testcase_06 | AC | 1 ms
13,056 KB |
testcase_07 | AC | 1 ms
12,068 KB |
testcase_08 | AC | 2 ms
13,056 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 1 ms
5,248 KB |
testcase_12 | AC | 1 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 100 ms
7,552 KB |
testcase_16 | AC | 85 ms
7,552 KB |
testcase_17 | AC | 51 ms
7,808 KB |
testcase_18 | AC | 141 ms
7,680 KB |
testcase_19 | AC | 37 ms
7,296 KB |
testcase_20 | AC | 127 ms
7,808 KB |
testcase_21 | AC | 69 ms
7,680 KB |
testcase_22 | AC | 80 ms
7,552 KB |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
コンパイルメッセージ
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
ソースコード
main :: IO () main = do n <- getLine s <- getLine print $ solve s 0 solve :: String -> Int -> Int solve [] acc = acc solve xs acc | length xs < 3 = acc solve xs@('U' : xs') acc = solve (getNext xs) (acc + c) where steps = getSteps xs 0 c = foldl (\acc' step -> if findUMG xs 0 step == Found then acc' + 1 else acc') 0 steps solve xs acc = solve (getNext xs) acc data UMG = Found | NotFound | Over deriving (Show, Eq) findUMG :: String -> Int -> Int -> UMG findUMG s start step = if start + step + step + 1 > length s then Over else if s !! start == 'U' && s !! (start+step) == 'M' && s !! (start+step*2) == 'G' then Found else NotFound getNext :: String -> String getNext (x : xs) = dropWhile (/= 'U') xs getSteps :: String -> Int -> [Int] getSteps [] start = [] getSteps (x : []) start = [] getSteps (x : xs) start = if length d > 0 then start + i : getSteps d (start + i) else getSteps (drop 1 d) (start + i) where d = dropWhile (/='M') xs i = length xs - length d + 1