結果

問題 No.592 括弧の対応 (2)
ユーザー 👑 obakyanobakyan
提出日時 2019-04-28 22:49:27
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 123 ms / 5,000 ms
コード長 445 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 5,300 KB
実行使用メモリ 5,512 KB
最終ジャッジ日時 2023-08-23 08:42:23
合計ジャッジ時間 1,252 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 123 ms
5,248 KB
testcase_02 AC 119 ms
5,512 KB
testcase_03 AC 118 ms
4,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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
0