結果
問題 | No.22 括弧の対応 |
ユーザー | kuuso1 |
提出日時 | 2015-04-16 01:12:19 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 531 bytes |
コンパイル時間 | 8,238 ms |
コンパイル使用メモリ | 163,428 KB |
実行使用メモリ | 9,000 KB |
最終ジャッジ日時 | 2023-09-27 12:52:06 |
合計ジャッジ時間 | 1,764 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,920 KB |
testcase_01 | AC | 2 ms
6,956 KB |
testcase_02 | AC | 3 ms
6,996 KB |
testcase_03 | AC | 3 ms
8,352 KB |
testcase_04 | AC | 3 ms
7,704 KB |
testcase_05 | AC | 3 ms
7,492 KB |
testcase_06 | AC | 3 ms
8,324 KB |
testcase_07 | AC | 3 ms
7,728 KB |
testcase_08 | AC | 3 ms
7,380 KB |
testcase_09 | AC | 4 ms
8,232 KB |
testcase_10 | AC | 3 ms
7,512 KB |
testcase_11 | AC | 3 ms
7,528 KB |
testcase_12 | AC | 4 ms
8,040 KB |
testcase_13 | AC | 4 ms
9,000 KB |
testcase_14 | AC | 2 ms
7,084 KB |
testcase_15 | AC | 4 ms
8,048 KB |
testcase_16 | AC | 4 ms
8,404 KB |
testcase_17 | AC | 3 ms
6,960 KB |
testcase_18 | AC | 3 ms
6,916 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 ) Main.hs:7:1: warning: [GHC-94817] [-Wtabs] Tab character found here, and in 8 further locations. Suggested fix: Please use spaces instead. | 7 | [n,k] <- (map read . words) <$> getLine | ^^^^^^^^ [2 of 2] Linking a.out
ソースコード
import Control.Monad import Control.Applicative import Data.List main ::IO() main=do [n,k] <- (map read . words) <$> getLine s <- getLine putStrLn $ show ( solve s k n ) solve :: String -> Int -> Int -> Int solve s k n = let res = f s [1..n] [] trgt = res !! (k-1) res2 = [snd x|x <- (zip res [1..n]),(fst x)==trgt, (snd x)/=k] in head res2 f:: String -> [Int] -> [Int] -> [Int] f "" _ _ = [] f s (x:xs) ys | (head s) == '(' = x:(f (tail s) xs (x:ys)) | otherwise = head ys : (f (tail s) xs (tail ys))