You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importsysreadl=sys.stdin.readlines=readl().rstrip()
result= []
deff():
""" 이전 X 위치 = 첫 X 위치를 찾음 (처음이 점일 수도 있음) 순회 - X가 끝날 때까지 전진 - (이전 X 위치 ... 현재 X 위치)에 대해 채운다 - AAAA를 채우고, +4 index에서 재귀 호출 - 이전의 채움 결과가 -1이면: - BB를 채우고, +2 index에서 재귀 호출 - 이 채움 결과도 -1이면 -1 출력 후 종료 이후에 구현하면서 조금씩 보완 """i=0whilei<len(s):
cnt=0whilei<len(s) ands[i] =='.':
i+=1cnt+=1result.append("."*cnt)
x_start=iwhilei<len(s) ands[i] =='X':
i+=1iffill(x_start, i) ==-1:
return-1return''.join(result)
deffill(si, ei_exclusive):
ifsi>ei_exclusive:
return-1elifsi==ei_exclusive:
return0else:
result.append("AAAA")
iffill(si+4, ei_exclusive) ==-1:
result.pop()
result.append("BB")
iffill(si+2, ei_exclusive) ==-1:
result.pop()
return-1else:
return0else:
return0print(f())
Problem link
https://www.acmicpc.net/problem/1343
Problem abstraction
Design(Plan) algorithm
Algorithm idea
Pseudo-code
Validate algorithm
Impl
Self-feedback
구조적 접근: 문제를 추상화하여 구조적으로 접근했는가?
구현하면서 보완하지 말자. 계획을 최대한 세운 후 구현하자.
사고력: 알고리즘을 완전히 이해했는가? (충분한 사고력을 가졌는가?)
replace idea
https://www.acmicpc.net/source/37193337
split + 길이를 4로 나누고 2로 나눈 값만큼 AAAA, BB를 붙이는 idea
https://www.acmicpc.net/source/37212464
좀더 간단한 아이디어들이 있다
첫 번째 아이디어가 아니라, 다양한 후보 아이디어들을 생각해본 후 선택하자
구현력: 알고리즘을 신속, 정확하게 구현했는가?
The text was updated successfully, but these errors were encountered: