結果
問題 | No.482 あなたの名は |
ユーザー | くれちー |
提出日時 | 2017-02-25 02:47:02 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,066 bytes |
コンパイル時間 | 3,121 ms |
コンパイル使用メモリ | 157,652 KB |
実行使用メモリ | 21,464 KB |
最終ジャッジ日時 | 2023-09-01 22:02:12 |
合計ジャッジ時間 | 9,403 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,988 KB |
testcase_01 | AC | 3 ms
6,996 KB |
testcase_02 | AC | 2 ms
6,960 KB |
testcase_03 | AC | 3 ms
6,980 KB |
testcase_04 | AC | 3 ms
6,936 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 62 ms
21,464 KB |
testcase_08 | AC | 32 ms
16,120 KB |
testcase_09 | AC | 4 ms
8,492 KB |
testcase_10 | AC | 32 ms
14,152 KB |
testcase_11 | AC | 43 ms
16,448 KB |
testcase_12 | AC | 62 ms
21,436 KB |
testcase_13 | AC | 32 ms
16,016 KB |
testcase_14 | AC | 22 ms
13,436 KB |
testcase_15 | TLE | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Data.List (findIndex) swap :: [a] -> Int -> Int -> [a] swap xs a b = fst t1 ++ [xs !! pred j] ++ fst t2 ++ [xs !! pred i] ++ t3 where i = min a b j = max a b t1 = splitAt (pred i) xs t2 = splitAt (pred $ j - i) (tail . snd $ t1) t3 = tail . snd $ t2 rep :: Integral a => [Int] -> [Int] -> Int -> a -> a rep ds idxs i cnt | i > length ds = cnt | ds !! (pred i) == i = rep ds idxs (succ i) cnt | otherwise = rep (swap ds i (idxs !! (pred i))) (swap idxs (ds !! pred i) (ds !! pred (idxs !! pred i))) (succ i) (succ cnt) solve :: Integral a => Int -> a -> [Int] -> Bool solve n k ds | cnt <= k && even (k - cnt) = True | otherwise = False where Just idxs = fmap (map succ) . sequenceA $ (\x -> findIndex (== x)) <$> [1..n] <*> pure ds cnt = rep ds idxs 1 0 main = do [n, k] <- map read . words <$> getLine ds <- map read . words <$> getLine putStrLn $ case solve n k ds of True -> "YES" False -> "NO"