[20250726] BOJ / G5 / 주기문으로 바꾸기 / 이종환 #549
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/1512
🧭 풀이 시간
25분
👀 체감 난이도
✏️ 문제 설명
주어진 DNA가 길이 L일 때, 이걸 길이 M보다 작거나 같은 주기문으로 바꿀 때, 바꾸는 문자열의 개수를 최소로 하는 프로그램을 작성하시오.
🔍 풀이 방법
주기길이 p라 가정하고 각각의 케이스에서
i i+p i+2p i+3p... 이 위치의 문자들의 갯수를 카운팅했다.
그렇게 나온 것들중에 a,t,g,c중에 무엇이 제일 많이 나왔는 지를 파악 후, 총 개수에서 뺐다.
-> 이게 바꿔야하는 문자의 개수이기에 이걸 모든 케이스에서 비교해서 구하였다.
⏳ 회고
간?신히 골드인듯.
문자 개수 아이디어 아니였으면 무조건 실버였다.