This is my personal note and might be some kind of user editorial/learning material for some people!
This is the fourth episode of this "note" series. I will write notes on problems (normally around 2400-ish problems), which are solved without looking at the editorial, that are both interesting and educational. I normally will spend a few hours on each problem so please be patient when reading the blog.
If you want to motivate me to write a continuation (aka note 5), a significant upvote from you would be well appreciated! If I received lots of downvotes (because I'm also spending a lot of time to write this and to learn latex only to express my ideas accurately to you guys), I'm probably not gonna continuing writing these blogs.
Problem statement:
Given a tree with $$$N$$$ nodes. You are given $$$Q$$$ queries. For each query, you are given an integer $$$K$$$ and an array $$${a}$$$ of length $$$K$$$.
We will color all these nodes in $$${a}$$$ in red.
$$$\sum_{i=1}^{Q}K_{i} \leq 10^5, 1 \leq N,Q\leq 10^5$$$.
Enemies will try to disconnect these nodes by removing other nodes that are not in $$${a}$$$. Find minimum nodes (that are not in $$${a}$$$) removed in order to disconnect those nodes in $$${a}$$$. Queries are not permanent (the nodes destroyed will be resetted after the query).
Again, always try the problem before looking at the solution.
Are you able to find the full solution from the hints?
Hope you guys learnt something from this blog.