WC simulation (1.2) T2 variable

variable

Background:

1.2 WC simulation T2

Analysis: network flow, maximum flow and minimum cut

In fact, this problem... At first glance, it's the minimum cut of network flow... As a result, my brain is full of split points in the examination room, and I'm happy that I didn't come up with a plan... Embarrassed face.

Consider that, obviously, W is to be funny. Finally, multiply it. For each variable, create a point I. obviously, the following three terms of each equation can be directly put forward for consideration together. For each answer w[i] statistics its contribution cnt[i]. For the positive and negative of cnt[i], after discussion, add 2 to one side of S à I and I à T
*abs(cnt[i]), and then for an equation a * |w[x] - w[y] |, we're at x,
The undirected edge of 2 * a between y indicates that if two different directions are selected, the middle edge must also be cut off, otherwise the same two are selected. Then we solve the limitation between variables. For x
< y directly forces X and T to connect to the INF side, and S and y to connect to the INF side. If x
< y, equivalent to the case where x = W, y = -W cannot exist, then directly X-Y connects the directed edge of INF, for X
==Y, just connect x to y to the edge of INF and y to X to the edge of INF. Then add the minimum cut of the original graph and the answer of the default value at the beginning.