Tenth multi-school hrbeu & HDU 3931 cross the fire (minimum weight cut + split point + bt Architecture)

Source: Internet
Author: User
A hero is going to surpass the minefield. hero has a certain amount of blood, and a certain amount of blood is required to touch the mine. The mine has a known radius and lethal force. Ask hero if he can pass through the minefield alive, it consumes the least amount of blood;

Question: We map all circles to vertices on an undirected graph, and link any two intersecting circles (including tangent and inclusion) to a undirected edge. We regard the upper boundary as a logical source point, the lower boundary is regarded as a logical sink point, and all the circles that intersect with it are connected to them respectively to a directed edge.
The model is abstracted as if there is an independent track from the source point to the sink point, then people must touch the thunder once, and people want to pass through the street, which means to destroy these independent tracks, the connectivity between the source and sink is lost.
This is obviously an undirected graph's least weighted point cut problem.
All the interior points except the source sink points are split, and the original vertex weight is converted to the edge capacity. The edge capacity of other edges is infinite, and then the stream is compressed from the source point to the sink point.
Finally, the final answer is to compare the maximum flow value with the initial physical strength.

The focus of the network flow is the diagram. After reading the diagram, the AC will be directly completed.

 

# Include <cstdio> # include <cstring> const int maxn = 255; const int maxn = 550; const int INF = 1 <25; const int S = 0; int l, w, N, P; struct edge {int V, next, W;} edge [maxn * maxn]; int head [maxn], CNT; // for SAP void addedge (int u, int V, int W) {edge [CNT]. V = V; edge [CNT]. W = W; edge [CNT]. next = head [u]; head [u] = CNT ++; edge [CNT]. V = u; edge [CNT]. W = 0; edge [CNT]. next = head [v]; head [v] = CNT ++;} int SAP (INT t) {int pre [maxn], c Ur [maxn], DIS [maxn], gap [maxn]; int flow = 0, Aug = inf, U; bool flag; For (INT I = 0; I <= T; ++ I) {cur [I] = head [I]; Gap [I] = dis [I] = 0 ;} gap [s] = t + 1; u = pre [s] = s; while (DIS [s] <= T) {flag = 0; for (Int & J = cur [u]; ~ J; j = edge [J]. next) {int v = edge [J]. v; If (edge [J]. w> 0 & dis [u] = dis [v] + 1) {flag = 1; if (edge [J]. W <Aug) Aug = edge [J]. w; Pre [v] = u; u = V; If (u = T) {flow + = Aug; while (u! = S) {u = pre [u]; edge [cur [u]. w-= Aug; edge [cur [u] ^ 1]. W + = Aug;} Aug = inf;} break;} If (FLAG) continue; int mindis = t + 1; for (Int J = head [u]; ~ J; j = edge [J]. next) {int v = edge [J]. v; If (edge [J]. w> 0 & dis [v] <mindis) {mindis = dis [v]; cur [u] = J ;}} if (-- gap [dis [u] = 0) break; Gap [dis [u] = mindis + 1] ++; u = pre [u];} return flow;} int X [maxn], Y [maxn], R [maxn], p [maxn]; // For build graphbool intersect (int A, int B) {int Dis = (X [a]-X [B]) * (X [a]-X [B]) + (Y [a]-y [B]) * (Y [a]-y [B]); If (DIS <= (R [a] + R [B]) * (R [a] + R [B]) return true; else return false;} void build_gr APH () {int n = 2 * n; For (INT I = 1; I <= N; ++ I) {addedge (I, I + N, P [I]); If (Y [I] <= R [I]) addedge (0, I, INF ); if (Y [I] + R [I]> = W) addedge (I + n, n + 1, INF); For (Int J = I + 1; j <= N; ++ J) // If (intersect (I, j) addedge (I + N, J, INF), addedge (J + N, I, INF) ;}} void Init () {memset (Head,-1, sizeof (head); CNT = 0 ;}int main () {While (~ Scanf ("% d", & L, & W, & N, & P) {Init (); For (INT I = 1; I <= N; ++ I) scanf ("% d", x + I, Y + I, R + I, P + I ); build_graph (); int ans = p-SAP (2 * n + 1); If (ANS <0) printf ("Our hero has been killed \ n "); else printf ("% d \ n", ANS);} return 0 ;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.