[20250825] BOJ / P4 / 가희의 수열놀이 (Large) / 권혁준#741
Merged
ShinHeeEul merged 1 commit intomainfrom Aug 25, 2025
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/17163
🧭 풀이 시간
180분
👀 체감 난이도
✏️ 문제 설명
정수 MOD와 빈 수열 A가 주어지며, A에 할 수 있는 세 종류의 작업이 주어진다.
🔍 풀이 방법
어차피 MOD가 작업 횟수보다 크면 답은 항상 -1만 나온다. -> MOD <= Q인 경우만 고려함
0부터 MOD-1까지 스택을 MOD개 만들어놓고 각 스택에는 해당 수가 나온 A에서의 인덱스를 저장해둔다.
이 때 3번 작업에 대한 답은, 만약 0부터 MOD-1까지 안 나온 수가 있다면 -1이고 그렇지 않다면 0부터 MOD-1까지의 스택에서 가장 큰 인덱스 중 최솟값 v에 대해, (현재까지 나온 수의 개수) - v가 답이 된다.
이걸 빨리 구하려고, TreeSet으로 최신 인덱스들만 담아놓도록 구현했다.
⏳ 회고
최근 본 문제들 중에 제일 싫었던 문제임
채점 순서도 랜덤이라 몇 퍼에서 틀렸는지가 의미없고,
스택 쓰니까 메모리 초과인데 vector쓰면 맞음.
C++로 짜니까 맞는데 Java로 짜니까 틀림.