[20250415] BOJ / G1 / 순열 그래프의 연결성 판별 / 권혁준#310
Merged
ShinHeeEul merged 1 commit intomainfrom Apr 15, 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/7982
🧭 풀이 시간
29분

👀 체감 난이도
✏️ 문제 설명
1부터 N까지의 수가 하나씩 들어있는 순열 A가 있다.
순열 그래프는 N개의 정점으로 이루어진 무방향 그래프로, 두 정점 쌍 (i,j)사이에 i<j와 A[i]>A[j]를 모두 만족하면 간선이 존재한다.
이 순열 그래프의 모든 컴포넌트 구성을 구해보자.
🔍 풀이 방법
[사용한 알고리즘]
순열 A에서 최댓값을 기준으로 오른쪽에 있는 모든 원소들과는 연결되어 있음이 확실하다.
이 부분을 A에서 잘라내고 남은 부분에 대해 다시 최댓값을 구하면, 또 오른쪽 원소들과 모두 연결되어 있다.
....
이런 식으로 생각하면 덩어리들이 여러 개 생기는데, 이 덩어리들 각각의 min값을 구해보면 각 덩어리들이 서로 연결될 수 있는지 알 수 있다.
⏳ 회고
너무 어렵다