260106 : [BOJ 23288] 주사위 굴리기 2 #2280
Open
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.
🚀 이슈 번호
Resolve: {#2274}
🧩 문제 해결
스스로 해결: ✅
🔎 접근 과정
이동방향 회전, 주사위 굴리기 등 방향 관련으로 체크해야할 것이 많았음. 직접 몇가지 경우를 적어보면서 규칙을 찾고, 따로 함수로 빼서 구현. (
rolll(),rotate~~())연결된 같은 수를 가진 칸은 고정된 값이므로, 한번 dfs를 돌려 구한 값을 다른 배열에 저장해 중복 연산을 줄였다. (
setCount())시뮬레이션 문제의 경우 작은 단계로 나누고 순서에 따라 함수 이름을 먼저 적어 놓고, 각 로직을 하나씩 구현하는게 좀 더 안정적인 거 같음.
⏱️ 시간 복잡도
O(NM)그래프 탐색: N*M개의 노드에 대해서 4방향 체크를 함 + 백트래킹과 다르게 visited를 초기화 하지 않음(하는 경우 약 (3^NM)?)탐색이 이루어지기 때문.
💻 구현 코드