[20250312] BOJ / P5 / 순환 순열 / 신희을 #234
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/12104
🧭 풀이 시간
30 분
👀 체감 난이도
✏️ 문제 설명
두 바이너리 문자열 A와 B가 주어졌을 때, A와 XOR 했을 때, 0이 나오는 B의 순환 순열의 개수를 구하는 프로그램을 작성하시오.
순환 순열이란 순열 P = P0, P1, ..., PN-1이 있을 때, 왼쪽으로 k번 순환 이동시킨 순열이다. 즉, P를 k번 순환 이동 시키면,$P_i$ -> $P_{i + k mod n}$ 이 된다.
첫째 줄에 A와 XOR했을 때, 0이 나오는 B의 순환 순열의 개수를 출력한다.
🔍 풀이 방법
A를 두 배로 늘려주고 마지막만 빼준다. 예를 들어 A가 101이라면 10110으로 만들어준다.
그리고 A와 B의 kmp를 구해 겹치는 만큼 세준다.
⏳ 회고
kmp 기본 문제다. 이제 슬슬 응용 문제도 연습해야지