結果
問題 | No.482 あなたの名は |
ユーザー | くれちー |
提出日時 | 2017-02-25 02:47:02 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,066 bytes |
コンパイル時間 | 8,027 ms |
コンパイル使用メモリ | 170,112 KB |
実行使用メモリ | 175,744 KB |
最終ジャッジ日時 | 2024-06-11 03:48:29 |
合計ジャッジ時間 | 13,250 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
10,624 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 54 ms
18,944 KB |
testcase_08 | AC | 26 ms
13,568 KB |
testcase_09 | AC | 3 ms
5,504 KB |
testcase_10 | AC | 20 ms
11,008 KB |
testcase_11 | AC | 36 ms
14,080 KB |
testcase_12 | AC | 51 ms
18,816 KB |
testcase_13 | AC | 27 ms
13,568 KB |
testcase_14 | AC | 18 ms
10,496 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.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:9:38: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 9 | t2 = splitAt (pred $ j - i) (tail . snd $ t1) | ^^^^ Main.hs:10:14: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 10 | t3 = tail . snd $ t2 | ^^^^ [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"