結果

問題 No.3141 Balancing with X=>O Flip
コンテスト
ユーザー tomcat1233
提出日時 2025-05-16 21:55:10
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 415 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,694 ms
コンパイル使用メモリ 195,584 KB
実行使用メモリ 16,000 KB
最終ジャッジ日時 2026-07-10 18:00:27
合計ジャッジ時間 10,822 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
raw source code

f str s m
  | null s = null m
  | null m = f str ts [x]
  | [x, y] == str = f str ts tm
  | otherwise = f str ts (x : m)
  where
    (x : ts) = s 
    (y : tm) = m

main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  s <- getLine
  let
    x = length $ filter (=='(') s
    y = length $ filter (==')') s
    bl1 = f "()" s []
    bl2 = f ")(" s []
    bl = bl1 || bl2
  putStrLn $ if bl then "Yes" else "No"
0