結果

問題 No.457 (^^*)
ユーザー cielciel
提出日時 2016-12-08 21:19:40
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 464 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 11,400 KB
実行使用メモリ 19,880 KB
最終ジャッジ日時 2023-08-19 02:32:02
合計ジャッジ時間 7,242 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,324 KB
testcase_01 AC 82 ms
15,004 KB
testcase_02 AC 82 ms
15,092 KB
testcase_03 AC 80 ms
15,280 KB
testcase_04 AC 80 ms
15,092 KB
testcase_05 AC 80 ms
15,348 KB
testcase_06 AC 82 ms
15,200 KB
testcase_07 WA -
testcase_08 AC 154 ms
15,216 KB
testcase_09 AC 357 ms
15,144 KB
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
def solve(s)
	al=[]
	ar=[]
	ah=[0]*s.size
	as=[]
	s.size.times{|i|
		if s[i]==?(
			al<<i
		elsif s[i]==?)
			ar<<i
		elsif s[i]=='^'
			ah[i]+=1
		elsif s[i]=='*'
			as<<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
		s=as.bsearch{|e|e>=hidx}||s.size
		ret+=1 if s<r
	}}
	ret
end
s=gets.chomp
puts [solve(s),solve(s.reverse.tr('()',')('))]*' '
0