結果
問題 | No.482 あなたの名は |
ユーザー | くれちー |
提出日時 | 2017-02-25 09:33:13 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,189 bytes |
コンパイル時間 | 2,928 ms |
コンパイル使用メモリ | 211,032 KB |
実行使用メモリ | 171,944 KB |
最終ジャッジ日時 | 2023-09-02 07:58:11 |
合計ジャッジ時間 | 8,022 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,164 KB |
testcase_01 | AC | 2 ms
7,304 KB |
testcase_02 | AC | 2 ms
7,228 KB |
testcase_03 | AC | 3 ms
7,184 KB |
testcase_04 | AC | 3 ms
7,244 KB |
testcase_05 | AC | 3 ms
7,176 KB |
testcase_06 | AC | 3 ms
7,312 KB |
testcase_07 | AC | 12 ms
14,884 KB |
testcase_08 | AC | 9 ms
13,344 KB |
testcase_09 | AC | 3 ms
7,940 KB |
testcase_10 | AC | 12 ms
13,092 KB |
testcase_11 | AC | 11 ms
14,928 KB |
testcase_12 | AC | 12 ms
15,020 KB |
testcase_13 | AC | 12 ms
13,328 KB |
testcase_14 | AC | 6 ms
11,012 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 Prelude hiding (tail, length, map, splitAt, (++), (!!)) import Data.Vector (!!) :: Vector a -> Int -> a v !! x = v ! (pred x) swap :: Vector a -> Int -> Int -> Vector a swap xs a b = fst t1 ++ singleton (xs !! j) ++ fst t2 ++ singleton (xs !! 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 => Vector Int -> Vector Int -> Int -> a -> a rep ds idxs i cnt | i > length ds = cnt | ds !! i == i = rep ds idxs (succ i) cnt | otherwise = rep (swap ds i (idxs !! i)) (swap idxs (ds !! i) (ds !! (idxs !! i))) (succ i) (succ cnt) solve :: Integral a => Int -> a -> Vector Int -> Bool solve n k ds | cnt <= k && even (k - cnt) = True | otherwise = False where Just idxs = fmap (fmap succ) . sequenceA $ (\x -> findIndex (== x)) <$> generate n succ <*> pure ds cnt = rep ds idxs 1 0 main = do [n, k] <- fmap read . words <$> getLine ds <- fromList . fmap read . words <$> getLine putStrLn $ case solve n k ds of True -> "YES" False -> "NO"