結果
| 問題 | 
                            No.1133 キムワイプイーター
                             | 
                    
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-09-25 08:33:38 | 
| 言語 | Haskell  (9.10.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,233 bytes | 
| コンパイル時間 | 8,146 ms | 
| コンパイル使用メモリ | 168,448 KB | 
| 実行使用メモリ | 62,976 KB | 
| 最終ジャッジ日時 | 2024-06-28 05:44:35 | 
| 合計ジャッジ時間 | 12,510 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | TLE * 1 -- * 30 | 
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import qualified Data.List as L
main :: IO ()
main = do
  [n, _m] <- map read . words <$> getLine
  s <- getLine
  putStr $ solve n s
solve :: Int -> [Char] -> String
solve n =
  unlines
  . map (unwords . map showBool)
  . solve' n
  where
    showBool :: Bool -> String
    showBool b = if b then "0" else "1"
solve' :: Int -> [Char] -> [[Bool]]
solve' n cs = solve'' n cs [(0, n)]
solve'' :: Int -> [Char] -> [(Int, Int)] -> [[Bool]]
solve'' n [] ps = fromCoords n $ L.nub ps
solve'' n (c:cs) ps@((x, y):_) = solve'' n cs ((x', y'):ps)
  where x' =
          case c of
            'R' -> x + 1
            'L' -> x - 1
            _   -> x
        y' =
          case c of
            'U' -> y - 1
            'D' -> y + 1
            _   -> y
solve'' _ _ [] = [[]] -- unreachable
fromCoords :: Int -> [(Int, Int)] -> [[Bool]]
fromCoords n ps =
  fromCoords' ps
  $ replicate (n + 1) (replicate (n + 1) False)
  where
    fromCoords' :: [(Int, Int)] -> [[Bool]] -> [[Bool]]
    fromCoords' [] bs = bs
    fromCoords' ((x, y):qs) bs =
        fromCoords' qs
        $ update y (update x True (bs!!y)) bs
        where
            update :: Int -> a -> [a] -> [a]
            update i a as = take i as ++ [a] ++ drop (i + 1) as