JOI 2013 - Synchronization
Author: Benjamin Qi
Method 1 - ?
When deleting an edge, remember how many systems that edge was used to synchronize. Also, each moment there is a connected component, all computers in the component have the same value.
^ This is I think
If we use HLD or LCT then it's .
Method 2 - Centroid Decomposition
Looks like is very fast!
vpi adj[MX];int N,M,Q,ans[MX];vi change[MX];vpi bad[MX];bool done[MX]; // processed as centroid yetint sub[MX],cen[MX]; // subtree size, centroid ancmap<int,list<int>> to[MX], from[MX];void dfs(int x, int p) { sub[x] = 1;trav(y,adj[x]) if (!done[y.f] && y.f != p)