結果
| 問題 |
No.457 (^^*)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-08 21:24:47 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 493 bytes |
| コンパイル時間 | 149 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 24,576 KB |
| 最終ジャッジ日時 | 2024-11-28 15:29:31 |
| 合計ジャッジ時間 | 14,284 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 TLE * 4 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/bin/ruby
def solve(s)
al=[]
ar=[]
ah=[0]*s.size
ast=[]
s.size.times{|i|
if s[i]==?(
al<<i
elsif s[i]==?)
ar<<i
elsif s[i]=='^'
ah[i]+=1
elsif s[i]=='*'
ast<<i
end
}
(1...s.size).each{|i|ah[i]+=ah[i-1]}
ret=0
al.each{|l|ar.each{|r|next if l>=r
hidx=(l...r).bsearch{|i|ah[i]>=ah[l]+2}
next if !hidx
st=ast.bsearch{|e|e>=hidx}||s.size
if st<r
#p [l,st,r]
ret+=1
end
}}
ret
end
s=gets.chomp
puts [solve(s),solve(s.reverse.tr('()',')('))]*' '