Skip to content

Conversation

@oncsr
Copy link
Contributor

@oncsr oncsr commented Feb 25, 2025

🧷 문제 링크

https://www.acmicpc.net/problem/16437

🧭 풀이 시간

7분

👀 체감 난이도

✏️ 문제 설명

  • 루트가 1이고 정점이 N개인 트리의 각 정점에 양 혹은 늑대들이 살고 있다.
  • 늑대는 양 한마리를 잡아먹을 수 있다.
  • 1번 섬에 도달할 수 있는 양은 최대 몇 마리인지 구해보자.

🔍 풀이 방법

[사용한 알고리즘]

  • DFS in Tree

  • 늑대가 a마리 살고 있다 -> 양이 -a마리 살고 있다 라고 바꿔서 생각했다.
  • DFS 돌면서 각 서브트리 별로, 양이 몇 마리 모이는 지 구하고, 음수이면 0으로 바꿔준다.

⏳ 회고

  • 풀이 아이디어가 참신하다

@oncsr oncsr added the success 👍 해설을 보지 않고 풀었을 때 label Feb 25, 2025
@ShinHeeEul ShinHeeEul merged commit e116abd into main Feb 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

success 👍 해설을 보지 않고 풀었을 때

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants