Files
Algorithm/백준/Silver/4949. 균형잡힌 세상/균형잡힌 세상.py

29 lines
607 B
Python

while True:
word = input()
stack = []
if word == ".":
break
for str in word:
if str in "([":
stack.append(str)
elif str == ")":
if stack and stack[-1] == "(":
stack.pop()
else:
stack.append(str)
break
elif str == "]":
if stack and stack[-1] == "[":
stack.pop()
else:
stack.append(str)
break
if stack:
print("no")
else:
print("yes")