[20250821] BOJ / G1 / 2048(Easy) / 이종환 #709
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/12100
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
이 문제에서 다루는 2048 게임은 보드의 크기가 N×N 이다. 보드의 크기와 보드판의 블록 상태가 주어졌을 때, 최대 5번 이동해서 만들 수 있는 가장 큰 블록의 값을 구하는 프로그램을 작성하시오.
🔍 풀이 방법
결국 순수 구현인데, 이걸 어떻게 표현할까 많이 고민했다. 그런데 방향에 따라서 대입하거나 꺼내오는 값이 바뀌는 파트가 별로 없어서 그냥 무식하게 if문으로 나눴다.
숫자가 합쳐지는 것의 경우 줄마다 큐를 생성한 후, 각 줄에서 0이아닌 수를 다 큐에 넣고, 다시 꺼내는 방식으로 구현하였다. 이를 통해 이제 합쳐져서 생긴 수에 또 다른 수를 또 합쳐버리는 실수를 방지하였다.
⏳ 회고
으 헷갈려