반응형
swexpertacademy.com/main/learn/course/subjectList.do?courseId=AVuPDN86AAXw5UW6
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
T = int(input())
for tc in range(1, T+1):
tmp = str(input())
tmp_list = []
for i in range(len(tmp)):
# 열기
if tmp[i] == '(':
tmp_list.append('(')
if tmp[i] == '{':
tmp_list.append('{')
# 닫기
if tmp[i] == ')':
if not tmp_list:
tmp_list.append(')')
else:
if tmp_list[-1] == '(':
tmp_list.pop()
else:
tmp_list.append(')')
if tmp[i] == '}':
if not tmp_list:
tmp_list.append('}')
else:
if tmp_list[-1] == '{':
tmp_list.pop()
else:
tmp_list.append('}')
if not tmp_list:
print("#{} {}".format(tc, 1))
else:
print("#{} {}".format(tc, 0))
반응형
'알고리즘 > SWEA' 카테고리의 다른 글
[파이썬] [SWEA] 4873. [파이썬 S/W 문제해결 기본] 4일차 - 반복문자 지우기 (0) | 2021.02.25 |
---|---|
[파이썬] [SWEA] 4871. [파이썬 S/W 문제해결 기본] 4일차 - 그래프 경로 (0) | 2021.02.25 |
[파이썬] [SWEA] 11315. 오목 판정 (0) | 2021.02.25 |
[파이썬] [SWEA] 4047. 영준이의 카드 카운팅 (0) | 2021.02.25 |
[파이썬] [SWEA] 2005. 파스칼의 삼각형 (0) | 2021.02.25 |
댓글