[20250721] BOJ / G3 / 소문난 칠공주 / 이종환 #519
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/1941
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
여학생반의 자리 배치도가 주어졌을 때, ‘소문난 칠공주’를 결성할 수 있는 모든 경우의 수를 구하는 프로그램을 작성하시오.
칠공주는 연결되어있어야한다. 그리고 이때 S가 최소 4개 이상이어야 한다.
'S'(이다‘솜’파의 학생을 나타냄) 또는 'Y'(임도‘연’파의 학생을 나타냄)을 값으로 갖는 5*5 행렬이 공백 없이 첫째 줄부터 다섯 줄에 걸쳐 주어진다.
🔍 풀이 방법
25C7 가 몇만 수준인걸 보고 바로 조합으로 진행하였다.
그런데 모두 하나로 연결되어있는 걸 증명하는걸 고려안했었다.
그래서 그냥 무식하게 temp라는 세트에다가 칠공주 중 랜덤한 한 좌표 넣고, 반복문을 돌리며 연결되어있는 지 확인하였다.
⏳ 회고
조합으로 풀긴 했는데, set 사용 + 무식한 반복문을 써서 시간초과 간신히 안났다... 좀 더 좋은 방법이 있을 것 같다.