結果
| 問題 | No.592 括弧の対応 (2) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-11-11 18:08:12 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 317 ms / 5,000 ms | 
| コード長 | 347 bytes | 
| コンパイル時間 | 1,641 ms | 
| コンパイル使用メモリ | 173,696 KB | 
| 実行使用メモリ | 49,408 KB | 
| 最終ジャッジ日時 | 2024-11-24 19:20:17 | 
| 合計ジャッジ時間 | 3,326 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 3 | 
コンパイルメッセージ
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 Data.List
import Control.Monad
main = getLine >> getLine >>= mapM_ print . solve
solve :: String -> [Int]
solve = map snd . sort . snd . foldl' f ([], []) . zip [1..]
  where
    f :: ([Int], [(Int, Int)]) -> (Int, Char) -> ([Int], [(Int, Int)])
    f (xs, ans) (i, '(') = (i:xs, ans)
    f (x:xs, ans) (i, ')') = (xs, (x, i):(i, x):ans)
            
            
            
        