회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
게시판
그룹
더 보기
재채점 기록
블로그
도움말
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
반례 알려주시면 감사하겠습니다.
4949번 - 균형잡힌 세상
korean011216
2년 전
0
반례가 어떤 것이 있는지 궁금합니다..
while True: sm_left = [] sm_right = [] big_left = [] big_right = [] correct = 0 str1 = list(input()) if len(str1) > 0: # 빈칸 오류 방지 if str1[0] == "." and len(str1) == 1: # 종료 break if str1.count("(") != str1.count(")") or str1.count("[") != str1.count("]"): # 여는거 닫는거 갯수 다를 때 correct = 1 print("no") continue else: for i in range(len(str1)): new = [] if str1[i] == "(": sm_left.append(i) elif str1[i] == ")": sm_right.append(i) if len(sm_right) > len(sm_left): # 닫는게 먼저 나오면 correct = 1 break # 닫는거 나오면 그 괄호 사이에 있는거 추출 for j in range(sm_left[(-1)*len(sm_right)], sm_right[len(sm_right)-1],1): new.append(str1[j]) if new.count("[") != new.count("]"): # '[', ']' 갯수 다르면 correct = 1 break elif str1[i] == "[": big_left.append(i) elif str1[i] == "]": big_right.append(i) if len(big_right) > len(big_left): # 닫는게 먼저 나오면 correct = 1 break # 닫는거 나오면 그 괄호 사이에 있는거 추출 for p in range(big_left[(-1)*len(big_right)], big_right[len(big_right)-1]): new.append(str1[p]) if new.count("(") != new.count(")"): # '(', ')' 갯수 다르면 correct = 1 break if correct == 1: print("no") else: print("yes")
댓글을 작성하려면
로그인
해야 합니다.
korean011216 2년 전
반례가 어떤 것이 있는지 궁금합니다..