結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
👑 |
提出日時 | 2019-04-28 22:49:27 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 445 bytes |
コンパイル時間 | 310 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-01 06:22:16 |
合計ジャッジ時間 | 1,120 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 31 ms
6,944 KB |
testcase_02 | AC | 31 ms
6,944 KB |
testcase_03 | AC | 30 ms
6,944 KB |
ソースコード
local n, k = io.read("*n", "*n", "*l") local str = io.read() local s = "" local mem = {} local taiou = {} for i = 1, n do taiou[i] = 0 end local cur = 0 for i = 1, n do s = string.sub(str, i, i) if(s == "(") then if(i == 1) then mem[1] = 1 cur = 1 else cur = cur + 1 mem[cur] = i end else taiou[mem[cur]] = i taiou[i] = mem[cur] cur = cur - 1 end end for i = 1, n do print(taiou[i]) end