import qualified Data.ByteString.Char8 as B import qualified Data.Vector.Unboxed.Mutable as V import Data.Int (Int64) main :: IO () main = do (n, k) <- fmap toTuple $ B.getLine ds <- B.getLine vec <- V.unsafeNew n mapM_ ((\(i, v) -> V.unsafeWrite vec i v) . convert) . zip [0..] $ B.words ds result <- proc n k 0 vec putStrLn result toTuple :: B.ByteString -> (Int, Int64) toTuple = (\[x, y] -> (read . B.unpack $ x, read . B.unpack $ y)) . B.words convert :: (Int, B.ByteString) -> (Int, Int) convert (i, v) = (i, flip (-) 1 . read . B.unpack $ v) proc :: Int -> Int64 -> Int -> V.IOVector Int -> IO String proc n k i _ | k < 0 = return "NO" | n == i = return $ if odd k then "NO" else "YES" proc n k i xs = do a1 <- V.unsafeRead xs i if a1 == i then proc n k (i + 1) xs else V.unsafeSwap xs i a1 >> proc n (k - 1) i xs