[20251112] BOJ / P4 / 이게 게임이냐? / 권혁준 #1388
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/26606
🧭 풀이 시간
45분
👀 체감 난이도
✏️ 문제 설명
서로 다른 수가 적힌 N개의 카드 덱으로 1인용 보드 게임을 진행한다.
테이블에는 오름차순으로 내려놓을 수 있는 더미 2개, 내림차순으로 내려놓을 수 있는 더미 2개가 있고, 처음에는 모두 비어있다.
내려놓을 카드에 적힌 수와 각 더미의 가장 위에 적힌 수의 차이가 정확히 10이면 오름차순/내림차순이 아니더라도 내려놓을 수 있다.
덱에서 뽑는 카드의 순서가 정해져 있을 때,
위 과정을 거쳐 덱에 있는 모든 카드를 더미에 내려놓을 수 있는지 알아보자.
🔍 풀이 방법
오름차순 더미에 있는 카드를 각각 c, d, 내림차순 더미에 있는 카드를 각각 e, f라고 정의하고 bfs를 돌려서 해결했다.
⏳ 회고
코드를 더 깔끔하게 짤 수 있을 거 같은데 잘 안 떠오른다..