[20251109] BOJ / G4 / 램프 / 이강현 #1358
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/1034
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
램프가 N x M의 형태로 존재함.
각 열의 맨 아래에는 해당 열을 반전시키는 스위치가 있음.
행이 모두 켜졌을때, 램프가 켜졌다고 함.
이때, 최대한 램프를 켰을때 그 개수를 출력.
🔍 풀이 방법
맵, 브루트포스
행을 하나의 패턴으로 보고 맵에 개수와 함께 저장.
패턴을 순회하면서 0의 개수를 세기
0의 개수가 K보다 작거나 같으면서 0의 개수만큼 반전시킨후 남은 반전횟수가 짝수인지 확인
짝수여야 켰다 끄면서 상태를 유지할 수 있기 때문.
위 조건을 만족하면서 가장 많은 패턴 개수를 출력.
⏳ 회고
정확히 K번 스위치를 눌러야 한다는 것을 생각하지 못했음.
행을 하나의 패턴으로 보고 접근해야한다는 아이디어.