[20250912] BOJ / G5 / 톱니바퀴 (2) / 이준희 #872
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/15662
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
8개의 톱니에 N극 또는 S극이 있는 톱니바퀴가 있고
각 톱니바퀴들은 마주보는 톱니의 극이 서로 다를 때 회전이 영향을 받습니다.
(설명이 어려우니 문제를 읽어주세요)
이 때 주어짓 횟수 만큼 톱니바퀴를 회전 시킨 후
마지막 단계에서 톱니바퀴의 12시 방향이 S극인 톱니바퀴의 갯수를 구하는 문제입니다.
🔍 풀이 방법
구현문제였습니다.
각 톱니바퀴들은 queue를 이용해서 8개의 극을 관리했고
각 단계별로 회전시킬 톱니바퀴를 기준으로 다른 모든 톱니바퀴에 대해서
시계방향 / 반시계방향 / 미회전 을 체크한 후 rotate를 통해 회전 시켰습니다.
⏳ 회고
문제 자체는 빠르게 이해하고 어떻게 풀어야겠다는 생각도 빠르게 들었는데
구현하는데 시간이 많이 걸리는 문제였습니다.