Syslians/4주차#23
Open
syslians wants to merge 4 commits into
Hidden character warning
The head ref may contain hidden characters: "syslians/4\uc8fc\ucc28"
Open
Conversation
백준 11723
백준 11723: 집합 <문제 해결 과정> 백준 11723번은 대량 연산(최대 3,000,000번)을 처리해야 하는 집합 관리 문제로, 초기 ArrayList 접근법에서 시간 초과를 겪었습니다. indexOf 의 O(n) 복잡도가 병목이었고, 특히 all 연산 구현이 어려웠습니다. 이를 해결하기 위해 비트마스크를 도입, 단일 int 로 집합을 관리하며 모든 연산을 O(1) 로 최적화했습니다. 출력은 StringBuilder 로 모아 시간 초과를 방지했습니다. <핵심> - 비트마스크: 집합을 32비트 int로 표현. 비트마스크는 비트 연산이기에 O(1)로 구현 가능. - 효율성: 연산당 O(1) 메모리 4바이트 사용. - 직관: 집합을 20개 스위치로 생각, 비트로 조작.
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.
백준 11723: 집합
<문제 해결 과정>
백준 11723번 집합 문제는 대량 연산(최대 3,000,000번)을 처리해야 하는 집합 관리 문제로, 초기 ArrayList 접근법에서 시간 초과를 겪었습니다.
indexOf나 contains 같은 메서드의 O(n) 복잡도가 연산이 많아질수록 병목현상이 있었고 이에 따라 시간초과 문제가 발생했습니다. 특히 all 연산 구현이 어려웠습니다.
이를 해결하기 위해 비트마스크를 도입, 단일 int 로 집합을 관리하며 모든 연산을 O(1) 로 최적화했습니다. 출력은 StringBuilder 로 모아 시간 초과를 방지했습니다.
<핵심>