Skip to content

Conversation

@oncsr
Copy link
Contributor

@oncsr oncsr commented Sep 6, 2025

🧷 문제 링크

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

🧭 풀이 시간

25분

👀 체감 난이도

✏️ 문제 설명

트리에서 두 점 (u,v)의 경로를 따라 XOR한 값이 0이 되는 경우의 수를 구해보자.

🔍 풀이 방법

  • BFS

걍 아무거나 하나 루트로 잡고, 루트에서 어떤 점 v까지의 경로 xor을 dist[v]라고 하자.
(u,v)의 경로 xor이 0이라는 건 dist[u]와 dist[v]를 xor한 값이 0이라는 것과 동치임.

BFS로 dist배열을 채워줬고, dist값이 같은 점들의 개수를 이용해서 답을 구했다.

⏳ 회고

DFS 돌리니까 터지는데 BFS 돌리니까 맞음.
이건 억까 아닌가

@oncsr oncsr added the success 👍 해설을 보지 않고 풀었을 때 label Sep 6, 2025
@ShinHeeEul ShinHeeEul merged commit 0a2c435 into main Sep 6, 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