[20250715] BOJ / P3 / 자리 바꾸기 / 권혁준 #473
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/1906
🧭 풀이 시간
90분
👀 체감 난이도
✏️ 문제 설명
N명의 사람이 1~K번 팀 중 하나에 속해있다.
인접한 두 사람의 자리를 최소한으로 바꿔서 같은 팀끼리는 모두 연속되도록 만들어 보자.
🔍 풀이 방법
dist[i][j] = i번 팀이 j번 인덱스부터 시작해서 차례로 연속하도록 만드는 최소 스왑 횟수로 정의했다.누적 합으로 이 dist배열을 구해줬다.
최종 상태의 가짓수는 항상 K!이고, K가 매우 작으므로 완탐으로 모든 경우 중 최소가 되는 경우를 구했다.
⏳ 회고
왜 틀렸는지 진짜 모르겠는데, 완탐에서 잘못 됐을 가능성은 절대 없다 생각해서 아마도 dist배열을 이용하여 횟수 구하는 로직이 잘못 된 것 같다.
태그를 보니 Bit DP가 달려있는데, 진짜 감이 1도 안잡혀서 포기해야 하나 생각이 든다.
일단 내일 더 봐야겠다