結果

問題 No.678 2Dシューティングゲームの必殺ビーム
ユーザー ducktailducktail
提出日時 2018-08-28 15:32:22
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,169 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 151,424 KB
最終ジャッジ日時 2024-04-27 02:36:21
合計ジャッジ時間 674 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:7: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.
  |
7 | import Data.IntSet (IntSet)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

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 qualified Data.IntSet as IS
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

import Control.Applicative
import Control.Monad
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V
import Data.Vector.Mutable (IOVector, STVector)
import qualified Data.Vector.Mutable as VM
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import Control.Monad.ST

main :: IO ()
main = do
  [n, xlb, xrb] <- f
  solve [n, xlb, xrb] <$> replicateM n f >>= mapM_ print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> [[Int]] -> [Int]
solve [n, xlb, xrb] es = map f [1..n]
  where
    f i = if IS.member i st then 1 else 0
    st = runST $ do
      v <- VM.replicate 1281 0 :: ST s (STVector s Int)
      ev <- V.thaw $ V.fromList es :: ST s (STVector s [Int])
      forM_ [1 .. n] $ \i -> do
        [xl, _, xr, yd] <- VM.read ev (i-1)
        forM_ [max xlb xl .. min xrb xr] $ \x -> do
          j <- VM.read v x
          if j == 0
            then VM.write v x i
            else do
              [_,_,_,yd'] <- VM.read ev (j-1)
              when (yd > yd') $ VM.write v x i
      foldM (\st x -> do
                i <- VM.read v x
                return $ IS.insert i st
                ) IS.empty [xlb .. xrb]
0