結果
問題 | No.457 (^^*) |
ユーザー |
|
提出日時 | 2016-12-08 22:28:42 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 124 ms / 2,000 ms |
コード長 | 492 bytes |
コンパイル時間 | 60 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-12-26 08:42:27 |
合計ジャッジ時間 | 3,155 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/bin/ruby def solve(s) len=s.size al=[] ar=[] ah=[0]*len ast=[] len.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| hidx=(l...len).bsearch{|i|ah[i]>=ah[l]+2}||len st=ast.bsearch{|e|e>=hidx} break if !st ret+=ar.size-((0...ar.size).bsearch{|i|ar[i]>=st}||ar.size) } ret end s=gets.chomp puts [solve(s),solve(s.reverse.tr('()',')('))]*' '