結果

問題 No.482 あなたの名は
ユーザー atuk721atuk721
提出日時 2017-02-17 08:17:08
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 784 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 161,052 KB
実行使用メモリ 67,812 KB
最終ジャッジ日時 2023-08-29 06:19:07
合計ジャッジ時間 9,385 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
7,076 KB
testcase_03 AC 3 ms
7,108 KB
testcase_04 WA -
testcase_05 AC 2 ms
7,216 KB
testcase_06 WA -
testcase_07 AC 7 ms
11,276 KB
testcase_08 AC 5 ms
9,840 KB
testcase_09 AC 3 ms
7,788 KB
testcase_10 AC 5 ms
9,780 KB
testcase_11 WA -
testcase_12 AC 6 ms
11,192 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 433 ms
67,736 KB
testcase_17 AC 433 ms
67,636 KB
testcase_18 AC 433 ms
67,752 KB
testcase_19 WA -
testcase_20 AC 443 ms
67,744 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 413 ms
67,752 KB
testcase_27 AC 423 ms
67,696 KB
testcase_28 WA -
testcase_29 AC 423 ms
67,756 KB
testcase_30 AC 2 ms
7,084 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 #

import Data.Array.Base (unsafeRead, unsafeWrite)
import Data.Int (Int64)
import qualified Data.Array.IO as I

main :: IO ()
main = do
  (n, k) <- fmap ((\[a, b] -> (read a, read b)) . words) $ getLine :: IO (Int, Int64)
  ds <- fmap (map (flip (-) 1 . read) . words) $ getLine :: IO [Int]
  is <- I.newListArray (0, n - 1) ds :: IO (I.IOUArray Int Int)
  result <- sortCount n k 0 is
  putStrLn result

sortCount :: Int -> Int64 -> Int -> I.IOUArray Int Int -> IO (String)
sortCount n k i _
  | k < 0  = return "NO"
  | n == i = return $ if odd k then "NO" else "YES"
sortCount n k i xs = do
  a1 <- unsafeRead xs i
  if a1 == i
     then sortCount n k (i + 1) xs
     else do
      a2 <- unsafeRead xs a1
      unsafeWrite xs i a2
      unsafeWrite xs a1 a1
      sortCount n k i xs
0