fork download
  1. # your code goes here
  2. # bj 4949
  3. while True:
  4. text = input()
  5. stack = []
  6. for i in text:
  7. if i=='[' or i=='(':
  8. stack.append(i)
  9. elif '[' in stack and i==']':
  10. stack.pop()
  11. elif '(' in stack and i==')':
  12. stack.pop()
  13. elif '[' not in stack and i==']':
  14. stack.append(i)
  15. elif '(' not in stack and i==')':
  16. stack.append(i)
  17.  
  18. if text=='.':
  19. break
  20.  
  21. if not stack:
  22. print('yes')
  23. else:
  24. print('no')
Success #stdin #stdout 0.03s 9740KB
stdin
([[])).
.
stdout
yes