結果

問題 No.482 あなたの名は
ユーザー くれちー
提出日時 2017-02-10 23:18:46
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 549 bytes
コンパイル時間 9,555 ms
コンパイル使用メモリ 176,256 KB
実行使用メモリ 73,472 KB
最終ジャッジ日時 2024-12-29 04:40:19
合計ジャッジ時間 54,037 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 4 TLE * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import Data.List
import Control.Applicative

swap :: (a, b) -> (b, a)
swap (x, y) = (y, x)

eq :: Eq a => (a, a) -> (a, a) -> Bool
eq x y = x == y || swap x == y

solve :: Integral a => a -> a -> [a] -> String
solve n k ds
    | t2 < 0          = "NO"
    | t2 `mod` 2 == 0 = "YES"
    | otherwise       = "NO"
    where
        t1 = length $ filter (\(x, y) -> x /= y) $ nubBy eq $ zip ds [1..]
        t2 = k - fromIntegral t1

main = do
    [n, k] <- map read . words <$> getLine
    ds <- map read . words <$> getLine
    putStrLn $ solve n k ds
0