USACO Farm Updates

I’m currently working on the algorithm for the gold problem farm updates.
Here’s what i’ve written down so far:

  • connected components, dsu-type problem
  • we basically have groups of connected fully/partially-active or inactive cows

If there were only two operations, aka D and A, I could use DSU for this problem. However, I’m not sure what to do with the third operation, R.

Could someone lead me in the right direction for this algorithm? Thanks in advance

image

two active farms