結果
問題 |
No.457 (^^*)
|
ユーザー |
👑 |
提出日時 | 2019-04-29 10:46:02 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,276 bytes |
コンパイル時間 | 118 ms |
コンパイル使用メモリ | 6,688 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 00:36:49 |
合計ジャッジ時間 | 1,075 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
local str = io.read() local n = #str local toji = {} for i = 1, n + 1 do toji[i] = 0 end for i = n, 1, -1 do if(str:sub(i, i) == ")") then toji[i] = toji[i + 1] + 1 else toji[i] = toji[i + 1] end end local lcnt, rcnt = 0, 0 --left local lpos = 1 while(lpos ~= nil) do local bg = str:find("(", lpos, true) if(bg == nil) then lpos = nil else lpos = bg + 1 local me1 = str:find("^", bg + 1, true) if(me1 ~= nil) then local me2 = str:find("^", me1 + 1, true) if(me2 ~= nil) then local kome = str:find("*", me2 + 1, true) if(kome ~= nil) then lcnt = lcnt + toji[kome + 1] else break end else break end else break end end end local rpos = 1 while(rpos ~= nil) do local bg = str:find("(", rpos, true) if(bg == nil) then rpos = nil else rpos = bg + 1 local kome = str:find("*", bg + 1, true) if(kome ~= nil) then local me1 = str:find("^", kome + 1, true) if(me1 ~= nil) then local me2 = str:find("^", me1 + 1, true) if(me2 ~= nil) then rcnt = rcnt + toji[me2 + 1] else break end else break end else break end end end print(lcnt .. " " .. rcnt)