結果

問題 No.592 括弧の対応 (2)
ユーザー ducktail
提出日時 2017-12-31 19:52:38
言語 Scheme
(Gauche-0.9.15)
結果
AC  
実行時間 261 ms / 5,000 ms
コード長 537 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 6,948 KB
実行使用メモリ 29,536 KB
最終ジャッジ日時 2024-12-21 15:33:01
合計ジャッジ時間 2,007 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

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