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/1777
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
Inversion sequence의 i번째 원소에는 순열에서 i보다 뒤에 나오면서 i보다 작은 수의 개수이다.
Inversion sequence가 주어지면, 원래의 순열을 구해보자.
🔍 풀이 방법
수를 N부터 채워넣어보자.
N을 넣을 때는 Inversion sequence의 N번째 원소 S[N]에 따라서 N이 들어가는 위치가 결정된다.
오른쪽 끝에서부터 S[N]번째에 위치하게 된다.
N-1을 넣을 때는 이미 들어간 N을 제외하고, 오른쪽 끝에서부터 S[N-1]번째에 위치하게 된다.
...
이런 방식으로 구현을 시간 내에 하려면, 자연스럽게 구간 합을 빠르게 구할 방법이 필요해진다. -> 이 때 세그먼트 트리를 쓰면 된다.
⏳ 회고
Inversion은 국밥이 맞음