[20251028] BOJ / G4 / 주사위 굴리기 / 권혁준 #1254
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/14499
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
모든 면에 0이 적힌 주사위가 있다.
N * M 모양의 격자 어딘가에 주사위를 놓고 이리저리 굴린다.
굴릴 때마다 주사위가 있는 칸에 적힌 수가 0이면 주사위의 바닥 부분에 적힌 수가 복사된다.
0이 아닌 경우에는 칸에 적힌 수가 주사위의 바닥면으로 복사되고 칸에 적힌 수는 0이 된다.
굴러갈 때마다 주사위의 상단에 적힌 수를 출력해보자.
밖으로 나가는 명령이 주어지면 그 명령을 무시한다.
🔍 풀이 방법
주사위의 6면을 각각 int 변수로 갖는 주사위 클래스를 만들고 동서남북 이동을 함수로 구현했다. 바닥면과 상호작용하는 부분도 함수로 만들어서 그대로 시뮬레이션을 돌렸다.
⏳ 회고
C++에서 처음 class를 써봤다. 자바랑 비슷하면서도 먼가 좀 다른 거 같다