Skip to content

Conversation

@oncsr
Copy link
Contributor

@oncsr oncsr commented Nov 24, 2025

🧷 문제 링크

https://www.acmicpc.net/problem/20919

🧭 풀이 시간

60분

👀 체감 난이도

✏️ 문제 설명

$N$개의 정수로 이루어진 집합 $S$$Q$개의 연산을 수행해보자.
연산 종류는 다음과 같다.

$\texttt{findMin}(x)$

$\min(x \oplus s)$를 출력 $(s \in S)$

$\texttt{findMax}(x)$

$\max(x \oplus s)$를 출력 $(s \in S)$

$\texttt{add}(x)$

$S$$x$를 추가하고, $|S|$를 출력

$\texttt{removeMin}()$

$S$에 속한 가장 작은 수를 출력하고 $S$에서 제거

$\texttt{removeMax}()$

$S$에 속한 가장 큰 수를 출력하고 $S$에서 제거

🔍 풀이 방법

집합 $S$set으로 관리하고, 이진수를 저장하는 트라이도 구성한다.

1,2번째 연산은 트라이에서 부분 최적해만 쫓아 가면 해결 가능
3번째 연산에서는 $S$와 트라이에 같이 넣기
4,5번째 연산은 $S$에서 값을 찾고 트라이에서도 지워주기

⏳ 회고

트라이에서 삭제 구현하는 게 까다로웠음. 포인터가 너무 어렵다

@oncsr oncsr added the success 👍 해설을 보지 않고 풀었을 때 label Nov 24, 2025
@ShinHeeEul ShinHeeEul merged commit 1a1011f into main Nov 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

success 👍 해설을 보지 않고 풀었을 때

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants