We have set of vertixes $$$G$$$ and 4 types of queries:
- Add/Remove direct edge $$$(uv)$$$.
- Mark vertex $$$v$$$.
- Check for some vertex $$$v$$$ if there is a path from marked vertex $$$u$$$ to $$$v$$$.
$$$N <= 1000000, queries <= 1000$$$, Should be better $$$O(N^2)$$$, online.
I have no idea how to solve this, any hint?