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/19651
🧭 풀이 시간
240분
👀 체감 난이도
✏️ 문제 설명
길이 N인 수열 A가 있다.
두 가지 쿼리를 처리해보자.
🔍 풀이 방법
B[i] = A[i] - A[i-1]로 정의하고 이 B 배열로 세그먼트 트리를 구성하면, 1번 쿼리가 단순히 구간 덧셈 쿼리로 변한다.
구체적으로 쿼리 (1, i, j, x, y)가 다음과 같이 변함.
위 작업들을 모두 세그먼트 트리에서 레이지 배열로 처리하고, 2번 쿼리는 구조체를 정의해서 세그먼트 트리의 노드로 넣어 처리했다.
구조체 Node에 포함되는 값은
이렇게 정의하고 세그먼트 트리에서 하위 두 노드를 합치는 함수를 만들어줬다.
⏳ 회고
레이지 배열 안 쓰는 업데이트 함수를 지우니까 맞음. 뭐지????