일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 가장 긴 바이토닉 부분 수열 파이썬
- 게임 개발 파이썬
- 트리의 지름 파이썬
- SQL SERVER MIGRATION
- 다리 만들기 파이썬
- 백준 11054.가장 긴 바이토닉 부분 수열
- 프로그래머스 순위
- 프로그래머스 등굣길
- 백준 1516 게임 개발
- 백준 1613 역사
- 백준 1034 램프 파이썬
- 등굣길 파이썬
- 다중 컬럼 NOT IN
- 프로그래머스 가장 긴 팰린드롬
- 역사 파이썬
- 백준 1043 거짓말 파이썬
- 램프 파이썬
- 백준 2146 다리 만들기
- 백준 1238 파티 파이썬
- 프로그래머스 베스트앨범
- 백준 2352 반도체 설계 파이썬
- SWEA
- 가장 긴 팰린드롬 파이썬
- 프로그래머스 순위 파이썬
- 백준 1167 트리의 지름 파이썬
- 순위 파이썬
- SQL SERVER 장비교체
- 프로그래머스 여행경로
- 반도체 설계 파이썬
- 베스트앨범 파이썬
Archives
- Today
- Total
공부, 기록
5550. 나는 개구리로소이다 D4 파이썬 본문
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
def solution(croaks):
stack=list()
croaks=list(croaks)
croaklist=[0]*5
count = 0
for i in croaks:
if i == "c":
stack.append(i)
croaklist[0]=croaklist[0]+1
count = max(count, croaklist[0])
elif i == "r":
if "c" in stack:
if stack.count("c") > stack.count("r"):
stack.append(i)
croaklist[1]=croaklist[1]+1
else:
return -1
else:
return -1
elif i == "o":
if "c" in stack and "r" in stack:
if stack.count("r") > stack.count("o"):
stack.append(i)
croaklist[2]=croaklist[2]+1
else:
return -1
else:
return -1
elif i == "a":
if "c" in stack and "r" in stack and "o" in stack:
if stack.count("o") > stack.count("a"):
stack.append(i)
croaklist[3]=croaklist[3]+1
else:
return -1
else:
return -1
elif i == "k":
if "c" in stack and "r" in stack and "o" in stack and "a" in stack:
if stack.count("a") > stack.count("k"):
stack.append(i)
croaklist[4]=croaklist[4]+1
stack.pop(stack.index("c"))
stack.pop(stack.index("r"))
stack.pop(stack.index("o"))
stack.pop(stack.index("a"))
stack.pop(stack.index("k"))
for j in range(4):
croaklist[j]=croaklist[j]-1
else:
return -1
else:
return -1
if stack:
return -1
return count
def main():
T = int(input())
for test_case in range(1,T+1):
croak = input()
print('#{} {}'.format(test_case, solution(croak)))
main()
'코딩' 카테고리의 다른 글
7701. 염라대왕의 이름 정렬 D4 파이썬 (0) | 2020.08.23 |
---|---|
1238. [S/W 문제해결 기본] 10일차 - Contact D4 파이썬 (0) | 2020.08.23 |
4301. 콩 많이 심기 D4 파이썬 (0) | 2020.08.23 |
4530. 극한의 청소 작업 D4 파이썬 (0) | 2020.08.23 |
입국심사 파이썬 (0) | 2020.08.23 |