Uvalive 5905 Pool Construction min Cut, s-t cut nature Difficulty: 3

Source: Internet
Author: User

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&itemid=8&page=show_problem& problem=3916

This problem requires a filling + digging pit + building barrier method, so that the land on all the pits and grass between all the barriers, digging pit spend d per block, fill the cost f per block, build the barrier cost B every two pieces, attention does not require there must be pits, but the periphery of a lap must be no pits, so need to pre-fill good

Make St represents the flat, Ed stands for the pit, the right side for the cost, then the subject is to require a st-ed minimum cut, because s to the flat cost of 0, so do not build the edge, the same pit to Ed does not need to spend not to build the edge, each point to the adjacent point to build the edge, the capacity of the b,s to the To prevent the perimeter from being dug, the capacity is set to INF.

With St as the starting point, Ed as the end point, to find the maximum flow, that is, the smallest cut can
The problem at the beginning of the thought is DP, in fact, is a minimum cut, although there are 2,500 points, 50,000 sides around, but still can use the network flow, a start to think about how to deal with the barrier, but in fact, only need to each point and adjacent points are connected to each other, the horizontal flow of no meaning, This means that only the edge between the flat and the pit will limit the flow.

#include <cstdio> #include <cstring> #include <algorithm>using namespace std;const int maxn=5000; const int Maxm=5000000;const int inf=0x3fffffff;int first[maxn];struct edge{int nxt,from,t,f,c;} E[maxm];int w,h,d,fl,b,len;char maz[60][60];const int dx[4]={1,-1,0,0};const int Dy[4]={0,0,1,-1};int st,ed,num;int Dis[maxn],gap[maxn];bool in (int x,int y) {return x>=0&&x

  

Uvalive 5905 Pool Construction min Cut, s-t cut nature Difficulty: 3

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.