Algorithm/백준

4949번: 균형잡힌 세상 하나 또는 여러줄에 걸쳐서 문자열이 주어진다. 각 문자열은 영문 알파벳, 공백, 소괄호("( )") 대괄호("[ ]")등으로 이루어져 있으며, 길이는 100글자보다 작거나 같다. 각 줄은 마침표(".")로 끝난다 www.acmicpc.net 처음 시도 while(True): word=input() c=d=0 if word=='.': print('Yes') break else: for w in word: if w=='(': c+=1 if w==')': c-=1 if w=='[': d+=1 if w==']': d-=1 if c==0 and d==0: print('Yes') else: print('No') 단순히 괄호의 짝만 맞추면 되는 것으로 이해하고 접근했으나, 균형이 되려면 괄..
dduniverse
'Algorithm/백준' 카테고리의 글 목록 (4 Page)