結果

問題 No.482 あなたの名は
ユーザー alpha_virginisalpha_virginis
提出日時 2017-02-14 00:34:03
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 818 bytes
コンパイル時間 7,565 ms
コンパイル使用メモリ 161,136 KB
実行使用メモリ 14,260 KB
最終ジャッジ日時 2023-08-28 16:25:59
合計ジャッジ時間 10,504 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,964 KB
testcase_01 AC 2 ms
7,004 KB
testcase_02 AC 2 ms
7,024 KB
testcase_03 AC 2 ms
6,932 KB
testcase_04 AC 3 ms
7,068 KB
testcase_05 AC 2 ms
7,052 KB
testcase_06 AC 2 ms
6,992 KB
testcase_07 WA -
testcase_08 AC 3 ms
7,252 KB
testcase_09 AC 2 ms
7,096 KB
testcase_10 AC 3 ms
7,168 KB
testcase_11 AC 2 ms
7,368 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 3 ms
7,124 KB
testcase_15 WA -
testcase_16 AC 32 ms
14,256 KB
testcase_17 AC 32 ms
14,112 KB
testcase_18 AC 32 ms
14,196 KB
testcase_19 WA -
testcase_20 AC 32 ms
14,196 KB
testcase_21 WA -
testcase_22 AC 32 ms
14,156 KB
testcase_23 WA -
testcase_24 AC 32 ms
14,144 KB
testcase_25 WA -
testcase_26 AC 32 ms
14,168 KB
testcase_27 WA -
testcase_28 AC 32 ms
14,132 KB
testcase_29 WA -
testcase_30 AC 2 ms
7,000 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 #-}

import Data.Maybe
import qualified Data.ByteString.Char8 as C
import Control.Monad(forM_)
import Data.Int
import Data.List

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 template --

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

solve :: Int -> Int -> [Int] -> C.ByteString
solve n k xs = if diff' <= k && mod diff' 2 == mod k 2 then yes else no
  where
    diff = length $ filter (\(x,y) -> x /= y) $ zip xs [1..]
    diff' = if diff == 0 then 0 else diff - 1
0