260126 : [BOJ 12784] 인하니카 공화국 #2333
Open
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.
🚀 이슈 번호
Resolve: {#2331}
🧩 문제 해결
스스로 해결: ✅ 1h
🔎 접근 과정
처음엔 노드 1에서 인접한 노드를 다 제거해야 안전한거 아닌가? 생각을 했는데 계속 해서 그림을 보니 깊이우선탐색을 통해 리프 노드의 가중치중 가장 작은것을 없애는 문제였다. 따라서 dp배열을 만들어 최소한의 가중치 값을 가져와 더해주며 최솟값을 출력해주었다.
⏱️ 시간 복잡도
O(TN)T만큼 반복 후 N개의 노드 반복
💻 구현 코드