[20250213] BOJ / G3 / K진 트리 / 권혁준 #104
Merged
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/11812
🧭 풀이 시간
60+분
👀 체감 난이도
✏️ 문제 설명
점이$N$ 개인 $Q$ 번 구해보자.
완전 K진 트리에서 두 점 사이의 거리를🔍 풀이 방법
⏳ 회고
X.get(i) == Y.get(j)로 하니까 틀리고X.get(i).equals(Y.get(j))로 하니까 맞았다.왜 틀렸지?
==연산자는 Primitive type에 대해서는 값 비교를 수행하고, Reference Type에 대해서는 주소 비교를 수행한다.equals메소드는 객체에 대한 값 비교를 수행한다.-> 경로 X, Y를 저장할 때 List의 타입을 Long으로 해줬고, Long은 Reference type이라 실제 값 비교가 제대로 되지 않은 듯하다.