import sys
pin=[]
while True:
sen=str(sys.stdin.readline())
arr=[]
flag=True
if sen[0]=='.':
break
else:
for x in list(sen):
if x=='(':
arr.append(x)
elif x==')':
if arr and arr[-1]=='(':
arr.pop()
else:
flag=False
break
elif x=='[':
arr.append('[')
elif x==']':
if arr and arr[-1]=='[':
arr.pop()
else:
flag=False
break
if not arr and flag==True:
pin.append('yes')
else:
pin.append('no')
for x in pin:
print(x)
'알고리즘 > 백준' 카테고리의 다른 글
백준-5014번(스타트링크)-python3 (6) | 2023.11.26 |
---|---|
백준-4963번(섬의 개수)-python3 (1) | 2023.11.26 |
백준-4948번(베르트랑 공준)-python3 (1) | 2023.11.26 |
백준-4673번(셀프 넘버)-python3 (0) | 2023.11.26 |
백준-4344번(평균은 넘겠지)-python3 (0) | 2023.11.26 |