T = int(input())
for test_case in range(1, T + 1):
sen = list(input())
ans = 1
check = []
for i in sen :
if i == '{' or i=='(' :
check.append(i)
elif i == ')' or i == '}':
if check :
a = check.pop()
if i==')' and a !='(':
ans = 0
break
elif i=='}' and a != '{':
ans = 0
break
else :
ans = 0
break
if check :
ans = 0
print('#{} {}'.format(test_case, ans))
'알고리즘' 카테고리의 다른 글
[SWEA] 5658. 보물상자 비밀번호 (Python) (0) | 2020.10.21 |
---|---|
[SWEA] 종이 붙이기 (Python) (0) | 2020.10.21 |
[SWEA] 그래프 경로 (Python) (0) | 2020.10.21 |
[SWEA] 반복문자 지우기 (Python) (0) | 2020.10.21 |
[백준] 2606. 바이러스 (Python) (0) | 2020.10.21 |