题解 | 小苯的括号疑问
小苯的括号疑问
https://www.nowcoder.com/practice/db2ad15e614943f2a56a7f419e9b932f
'''import sys
from numpy.core.defchararray import count
for line in sys.stdin:
a = line.split()
print(int(a[0]) + int(a[1]))'''
t=int(input())
for i in range(t):
ls=[]
str1=input()
if len(str1)==0:
print(str1)
for j in str1:
if j==')' and len(ls)!=0:
ls.pop()
else:
ls.append(j)
coun=len(ls)
if coun%2!=0:
print(-1)
elif len(str1)==2:
print('()')
else:
print('There are multiple solutions')
查看15道真题和解析