Skip to content

Conversation

@ShinHeeEul
Copy link
Contributor

🧷 문제 링크

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 기본 문제다. 이제 슬슬 응용 문제도 연습해야지

@ShinHeeEul ShinHeeEul added the success 👍 해설을 보지 않고 풀었을 때 label Mar 12, 2025
@ShinHeeEul ShinHeeEul self-assigned this Mar 12, 2025
@ShinHeeEul ShinHeeEul merged commit 4ba40bb into main Mar 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

success 👍 해설을 보지 않고 풀었을 때

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants