結果
問題 | No.769 UNOシミュレータ |
ユーザー | ducktail |
提出日時 | 2018-12-18 14:05:58 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,634 bytes |
コンパイル時間 | 14,106 ms |
コンパイル使用メモリ | 233,856 KB |
実行使用メモリ | 177,920 KB |
最終ジャッジ日時 | 2024-11-22 08:49:59 |
合計ジャッジ時間 | 40,878 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,496 KB |
testcase_01 | AC | 2 ms
116,352 KB |
testcase_02 | AC | 2 ms
10,496 KB |
testcase_03 | AC | 2 ms
116,480 KB |
testcase_04 | AC | 6 ms
14,848 KB |
testcase_05 | AC | 6 ms
9,472 KB |
testcase_06 | AC | 7 ms
14,848 KB |
testcase_07 | AC | 7 ms
177,920 KB |
testcase_08 | AC | 7 ms
14,848 KB |
testcase_09 | AC | 50 ms
20,480 KB |
testcase_10 | AC | 52 ms
20,224 KB |
testcase_11 | AC | 52 ms
170,240 KB |
testcase_12 | AC | 1,671 ms
65,824 KB |
testcase_13 | AC | 1,647 ms
59,136 KB |
testcase_14 | AC | 1,658 ms
59,136 KB |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | WA | - |
コンパイルメッセージ
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
ソースコード
import Control.Applicative import Control.Monad import Control.Monad.State import Data.Vector.Unboxed (Vector, (!), (//)) import qualified Data.Vector.Unboxed as V main :: IO () main = do [n, m] <- f solve n <$> replicateM m getLine >>= putStrLn . unwords . map show where f = map read <$> words <$> getLine solve :: Int -> [String] -> [Int] solve n xs = evalState (f xs) (V.replicate n 0, 0, 1, 0, 0) where f :: [String] -> State (Vector Int, Int, Int, Int, Int) [Int] f [] = do (v, t, dr, _, _) <- get let pt = (t - dr) `mod` n return [pt + 1, v ! pt] f ("number":rs) = do (v, t, dr, d2, d4) <- get let nt = (t + dr) `mod` n if d2 > 0 then do put (v // [(t, (v ! t) - 2 * d2)], nt, dr, 0, d4) f ("number":rs) else if d4 > 0 then do put (v // [(t, (v ! t) - 4 * d4)], nt, dr, d2, 0) f ("number":rs) else do put (v // [(t, (v ! t) + 1)], nt, dr, d2, d4) f rs f ("drawtwo":rs) = do (v, t, dr, d2, d4) <- get let nt = (t + dr) `mod` n if d4 > 0 then do put (v // [(t, (v ! t) - 4 * d4)], nt, dr, d2, 0) f ("drawtwo":rs) else do put (v // [(t, (v ! t) + 1)], nt, dr, d2 + 1, d4) f rs f ("drawfour":rs) = do (v, t, dr, d2, d4) <- get let nt = (t + dr) `mod` n if d2 > 0 then do put (v // [(t, (v ! t) - 2 * d2)], nt, dr, 0, d4) f ("drawfour":rs) else do put (v // [(t, (v ! t) + 1)], nt, dr, d2, d4 + 1) f rs f ("skip":rs) = do (v, t, dr, d2, d4) <- get let nt = (t + dr) `mod` n if d2 > 0 then do put (v // [(t, (v ! t) - 2 * d2)], nt, dr, 0, d4) f ("skip":rs) else if d4 > 0 then do put (v // [(t, (v ! t) - 4 * d4)], nt, dr, d2, 0) f ("skip":rs) else do let nnt = (nt + dr) `mod` n put (v // [(t, (v ! t) + 1)], nnt, dr, d2, d4) f rs f ("reverse":rs) = do (v, t, dr, d2, d4) <- get let nt = (t + dr) `mod` n if d2 > 0 then do put (v // [(t, (v ! t) - 2 * d2)], nt, dr, 0, d4) f ("reverse":rs) else if d4 > 0 then do put (v // [(t, (v ! t) - 4 * d4)], nt, dr, d2, 0) f ("reverse":rs) else do let nt' = (t - dr) `mod` n put (v // [(t, (v ! t) + 1)], nt', negate dr, d2, d4) f rs