結果

問題 No.482 あなたの名は
ユーザー alpha_virginisalpha_virginis
提出日時 2017-02-23 20:52:18
言語 Haskell
(9.8.2)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 1,097 bytes
コンパイル時間 10,591 ms
コンパイル使用メモリ 182,844 KB
実行使用メモリ 45,864 KB
最終ジャッジ日時 2023-08-30 21:36:05
合計ジャッジ時間 14,177 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,936 KB
testcase_01 AC 2 ms
6,996 KB
testcase_02 AC 2 ms
6,980 KB
testcase_03 AC 2 ms
6,876 KB
testcase_04 AC 3 ms
6,964 KB
testcase_05 AC 2 ms
6,952 KB
testcase_06 AC 2 ms
6,964 KB
testcase_07 AC 3 ms
7,216 KB
testcase_08 AC 3 ms
7,128 KB
testcase_09 AC 3 ms
6,972 KB
testcase_10 AC 2 ms
7,080 KB
testcase_11 AC 3 ms
7,152 KB
testcase_12 AC 2 ms
7,288 KB
testcase_13 AC 3 ms
7,184 KB
testcase_14 AC 3 ms
7,140 KB
testcase_15 AC 133 ms
45,676 KB
testcase_16 AC 133 ms
45,752 KB
testcase_17 AC 133 ms
45,772 KB
testcase_18 AC 134 ms
45,760 KB
testcase_19 AC 133 ms
45,692 KB
testcase_20 AC 133 ms
45,772 KB
testcase_21 AC 133 ms
45,752 KB
testcase_22 AC 133 ms
45,696 KB
testcase_23 AC 143 ms
45,692 KB
testcase_24 AC 133 ms
45,668 KB
testcase_25 AC 123 ms
45,796 KB
testcase_26 AC 123 ms
45,724 KB
testcase_27 AC 123 ms
45,732 KB
testcase_28 AC 123 ms
45,864 KB
testcase_29 AC 94 ms
44,472 KB
testcase_30 AC 3 ms
6,908 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Data.Maybe
import qualified Data.ByteString.Char8 as C
import Control.Monad(forM_)
import Data.Int
import Data.List
import Data.Array
import Data.Word
import Data.Bits
import qualified Data.IntMap as IntMap
import qualified Data.Map as Map
import Data.Functor

yes :: C.ByteString
yes = "YES"

no :: C.ByteString
no = "NO"

getInts :: IO [Int]
getInts = do
  ss <- C.getLine
  return $ map (fst . fromJust . C.readInt) $ C.words ss

getIntss :: Int -> IO [[Int]]
getIntss 0 = return []
getIntss n = do
  xs <- getInts
  xss <- getIntss (n - 1)  
  return $ xs : xss

-- end standard template --


main :: IO ()
main = do
  [n,k] <- getInts
  xs <- getInts
  let res = solve n k xs
  C.putStrLn res

solve :: Int -> Int -> [Int] -> C.ByteString
solve n k xs = if odd t == odd k && t <= k then yes else no
  where
    as = listArray (1,n) xs
    bs = array (1,n) [(i, f i i) | i <- [1..n]]
      where
        f s x = if (as ! x) == s then x else min x $ f s (as ! x)
    t = foldr (\i -> \m -> if bs ! i /= i then m + 1 else m) 0 [1..n]
0