結果

問題 No.495 (^^*) Easy
ユーザー tanson
提出日時 2025-10-11 00:19:31
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 6,386 ms
コンパイル使用メモリ 689,404 KB
実行使用メモリ 9,316 KB
最終ジャッジ日時 2025-10-11 00:19:38
合計ジャッジ時間 6,084 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

fun readStr () =
    let
        fun scan reader stream = SOME (StringCvt.splitl (not o Char.isSpace) reader (StringCvt.skipWS reader stream))
    in
        valOf (TextIO.scanStream scan TextIO.stdIn)
    end


exception BadInput

fun findAns s =
    let
        fun count nil (left, right) = (left, right)
          | count (#"#" :: tl) (left, right) = (left, right)  
          | count (#"(" :: #"^" :: #"^" :: #"*" :: #")" :: tl) (left, right) =
            count tl (left + 1, right)
          | count (#"(" :: #"*" :: #"^" :: #"^" :: #")" :: tl) (left, right) =
            count tl (left, right + 1)
          | count _ _ = raise BadInput
    in
        count (String.explode s) (0, 0)
    end


val () =
    let
        val s = readStr ()
        val (left, right) = findAns s
    in
        print (Int.toString left ^ " " ^ Int.toString right ^ "\n")  
    end
0