摘要: # [五行学说](https://iai.sh.cn/problem/28) 带权并查集。 我们发现,克一次相当于生两次。 如图,火、土、金的部分。 发现,这样这个问题就同食物链问题很像了。 ```cpp #include #include using namespace std; const in 阅读全文
posted @ 2023-10-08 20:16 wscqwq 阅读(5) 评论(0) 推荐(0) 编辑
摘要: # [P2024 [NOI2001] 食物链](https://www.luogu.com.cn/problem/P2024) 带权并查集。 我们维护每个点到根的距离,为 $0$ 表示同类,为 $1$ 表示吃根,$2$ 表示被根吃。 判断合法只需要将 $d_u,d_v$ 作差即可。 连接时可以 $f 阅读全文
posted @ 2023-10-08 20:06 wscqwq 阅读(3) 评论(0) 推荐(0) 编辑