회원가입
로그인
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번 - 균형잡힌 세상
sera5us
3년 전
0
모든 반례를 다해봐도 답이 다나오는데 자꾸 10퍼에서 실패합니다
# stack import sys fullString = [] bracketDict = {"(" : ")", ")" : "(","[" : "]","]" : "["} sequenceList = ["(",")","[","]"] def checkPalindrome(st): bracketList1 = [] bracketList2 = [] midTemp = [] for y in st: # 괄호만 남기기 try : bracketList1.append(bracketDict[y]) except: continue try: while True: if (len(bracketList1) + len(bracketList2)) % 2 != 0: print("no") break elif (len(bracketList1) + len(bracketList2) )== 0: print("yes") break else: if midTemp == bracketList2 and len(bracketList2) != 0: #detour infinite print("no") break if len(bracketList1) == 0: midTemp = bracketList2[:] bracketList1 = bracketList2[:] bracketList2.clear() continue try: if bracketDict[bracketList2[-1]] == bracketList1[0] and sequenceList.index(bracketList1[0]) < sequenceList.index(bracketList2[-1]): bracketList2.pop() bracketList1.pop(0) except: pass if (len(bracketList1) + len(bracketList2) )== 0: print("yes") break bracketList2.append(bracketList1.pop(0)) except: pass return "no" while True: f = sys.stdin.readline().rstrip() if f == '.': break fullString.append(f) for x in fullString: checkPalindrome(x)
changwook987
3년 전
0
이 입력에 대해 아무 출력도 없네요
[[]][]. .
댓글을 작성하려면
로그인
해야 합니다.
sera5us 3년 전
모든 반례를 다해봐도 답이 다나오는데 자꾸 10퍼에서 실패합니다