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/5000
🧭 풀이 시간
27분
👀 체감 난이도
✏️ 문제 설명
수열 A를 수열 B로 만들려고 한다.
사용할 수 있는 연산은, 어떤 연속된 세 원소 a, b, c를 골라, 순서를 c, a, b로 바꾼다.
연산을 이용해서 A를 B로 만들 수 있는지 알아보자.
🔍 풀이 방법
[사용한 알고리즘]
A를 B로 만들건데, B의 첫 수부터 맞춰주는 방식으로 접근했다.
B의 첫 수 B[1]에 대해, A에서의 B[1]의 위치가 홀수 번째라면, A에서 B[1]만 골라내서 그대로 맨 앞으로 가져올 수 있다.
(연산을 반복 적용하면 됨.)
그렇게 수가 두 개 남을때까지 위 과정을 반복한다.
이 때, A에서의 B[i]의 위치를 구하기 위해 세그먼트 트리를 사용해서, 이미 처리한 수들을 중복해서 세지 않도록 구현했다.
⏳ 회고
어렵다 매우