26 lines
331 B
Python
26 lines
331 B
Python
# Fill Input
|
|
|
|
input = ""
|
|
|
|
try:
|
|
with open("01.txt", 'r', encoding='utf-8') as file:
|
|
input += file.read()
|
|
except Exception as e:
|
|
print(f"An error occurred: {e}")
|
|
|
|
# Result
|
|
|
|
res1, res2 = 0, 0
|
|
|
|
for c in input:
|
|
match c
|
|
case '(':
|
|
res1 += 1
|
|
case ')':
|
|
res1 -= 1
|
|
|
|
if res1 < 0 and res2 == 0:
|
|
res2 = i+1
|
|
|
|
print(res1, res2)
|