結果
| 問題 | No.592 括弧の対応 (2) | 
| コンテスト | |
| ユーザー | 👑 | 
| 提出日時 | 2019-04-28 22:49:27 | 
| 言語 | Lua (LuaJit 2.1.1734355927) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 31 ms / 5,000 ms | 
| コード長 | 445 bytes | 
| コンパイル時間 | 148 ms | 
| コンパイル使用メモリ | 6,948 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-21 10:08:03 | 
| 合計ジャッジ時間 | 1,058 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 3 | 
ソースコード
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
            
            
            
        