結果

問題 No.592 括弧の対応 (2)
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2017-11-10 23:29:34
言語 Ruby
(3.3.0)
結果
AC  
実行時間 348 ms / 5,000 ms
コード長 222 bytes
コンパイル時間 52 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-05-03 14:40:25
合計ジャッジ時間 1,879 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
12,288 KB
testcase_01 AC 348 ms
14,848 KB
testcase_02 AC 342 ms
15,488 KB
testcase_03 AC 344 ms
14,848 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N=gets.to_i
st=[]
corr=[]
gets.chomp.each_char.with_index{|c, i|
    if c=='('
        st.push(i)
    else
        j = st.pop()
        corr[j] = i;
        corr[i] = j;
    end
}
corr.each_with_index{|v, i|
    puts v+1
}
0