結果

問題 No.592 括弧の対応 (2)
ユーザー ducktailducktail
提出日時 2017-12-31 19:52:38
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 235 ms / 5,000 ms
コード長 537 bytes
コンパイル時間 34 ms
コンパイル使用メモリ 5,304 KB
実行使用メモリ 27,100 KB
最終ジャッジ日時 2023-08-23 12:33:50
合計ジャッジ時間 1,792 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
12,096 KB
testcase_01 AC 233 ms
27,068 KB
testcase_02 AC 235 ms
27,100 KB
testcase_03 AC 233 ms
26,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (main args)
  (let* ([n (string->number (read-line))]
         [pl (string->list (read-line))]
         [rv (make-vector (+ n 1) 0)])
    (let loop ([st '()]
               [pl pl]
               [i 1])
      (cond [(null? pl) #t]
            [(char=? (car pl) #\() (loop (cons i st) (cdr pl) (+ i 1))]
            [else (vector-set! rv (car st) i)
                  (vector-set! rv i (car st))
                  (loop (cdr st) (cdr pl) (+ i 1))]))
    (vector-for-each-with-index (lambda (i x) (if (> i 0) (print x))) rv))
  0)
0