結果

問題 No.457 (^^*)
ユーザー compass19compass19
提出日時 2016-12-10 21:59:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,135 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 8,340 KB
最終ジャッジ日時 2023-08-19 10:35:07
合計ジャッジ時間 1,577 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,936 KB
testcase_01 AC 16 ms
8,024 KB
testcase_02 AC 15 ms
8,068 KB
testcase_03 AC 16 ms
8,020 KB
testcase_04 AC 16 ms
8,076 KB
testcase_05 AC 16 ms
8,072 KB
testcase_06 AC 16 ms
7,992 KB
testcase_07 AC 16 ms
8,032 KB
testcase_08 WA -
testcase_09 AC 17 ms
7,992 KB
testcase_10 WA -
testcase_11 AC 53 ms
8,072 KB
testcase_12 AC 21 ms
8,040 KB
testcase_13 AC 25 ms
8,340 KB
testcase_14 AC 17 ms
7,980 KB
testcase_15 AC 21 ms
7,988 KB
testcase_16 AC 24 ms
8,256 KB
testcase_17 AC 17 ms
7,996 KB
testcase_18 AC 16 ms
7,996 KB
testcase_19 AC 16 ms
8,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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

print(left_solve(), right_solve())
0