結果

問題 No.457 (^^*)
ユーザー compass19compass19
提出日時 2016-12-10 22:17:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,238 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 8,496 KB
最終ジャッジ日時 2023-08-19 10:37:21
合計ジャッジ時間 10,512 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,156 KB
testcase_01 AC 15 ms
8,024 KB
testcase_02 AC 15 ms
8,016 KB
testcase_03 AC 13 ms
7,940 KB
testcase_04 AC 13 ms
8,100 KB
testcase_05 AC 13 ms
8,008 KB
testcase_06 AC 13 ms
8,024 KB
testcase_07 AC 14 ms
7,940 KB
testcase_08 AC 14 ms
7,712 KB
testcase_09 AC 15 ms
7,792 KB
testcase_10 AC 20 ms
8,076 KB
testcase_11 AC 47 ms
8,076 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 15 ms
8,124 KB
testcase_15 AC 1,950 ms
8,212 KB
testcase_16 TLE -
testcase_17 AC 15 ms
8,048 KB
testcase_18 AC 14 ms
8,044 KB
testcase_19 AC 14 ms
8,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -----------
# yukicoder
# No.457 (^^*)
# http://yukicoder.me/problems/no/457
# -------


s = input()
left_pos = [i for i, k in enumerate(s) if k == '(']

def left_solve():
	res = 0
	tmp_stock = None
	first_index = None
	for i in left_pos:
		if tmp_stock is not None:
			if i < first_index:
				res += tmp_stock
				continue
			else:
				tmp_stock = None
				first_index = None
		tmp = s[i+1:]
		count = 0
		for j, elm in enumerate(tmp):
			if count < 2:
				if elm == '^':
					if first_index is None: first_index = i + j
					count += 1
			else:
				if elm == '*':
					tmp_stock = tmp[j+1:].count(')')
					res += tmp_stock
					break
	return res

def right_solve():
	res = 0
	tmp_stock = None
	first_index = None
	for i in left_pos:
		if tmp_stock is not None:
			if i < first_index:
				res += tmp_stock
				continue
			else:
				tmp_stock = None
				first_index = None
		tmp = s[i+1:]
		count = 0
		for j, elm in enumerate(tmp):
			if count < 1:
				if elm == '*':
					if first_index is None: first_index = i + j
					count += 1
			elif count < 2:
				if elm == '^':
					count += 1
			else:
				if elm == '^':
					tmp_stock = tmp[j+1:].count(')')
					res += tmp_stock
					break
	return res

print(left_solve(), right_solve())
0