結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-23 13:08:56 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,212 bytes |
| コンパイル時間 | 6,104 ms |
| コンパイル使用メモリ | 149,888 KB |
| 最終ジャッジ日時 | 2024-12-26 17:14:38 |
| 合計ジャッジ時間 | 7,683 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:8:1: error: [GHC-87110]
Could not load module ‘Data.IntSet’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
8 | import Data.IntSet (IntSet)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Main.hs:9:1: error: [GHC-87110]
Could not load module ‘Data.IntSet’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
9 | import qualified Data.IntSet as IS
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import Control.Applicative
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
main :: IO ()
main = solve <$> f <*> g >>= putStrLn
where
f = readil B.readInt <$> B.getLine
g = readiv B.readInt <$> B.getLine
solve :: [Int] -> Vector Int -> String
solve [n, k] v
| ct <= k && even (k - ct) = "YES"
| otherwise = "NO"
where
(ct, _) = V.ifoldl' f (0, IS.empty) v
f (ct, mm) i x
| i+1 == x = (ct, mm)
| otherwise = count (ct, mm) i
count (ct, mm) i
| IS.member (v ! i - 1) mm = (ct, IS.insert i mm)
| otherwise = count (ct+1, IS.insert i mm) (v ! i - 1)
readil :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr g
where
g s = do
(n, s') <- f s
return (n, B.dropWhile isSpace s')
readiv :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> Vector a
readiv f = V.unfoldr g
where
g s = do
(n, s') <- f s
return (n, B.dropWhile isSpace s')