【HDOJ5520】Number Link(费用流)】的更多相关文章

题意:NxM的格子有些上面有数字,现在要把奇数跟偶数配对连起来,其他的格子连成一个个回路, 单独的相邻两个格子相连也算是一个回路按两条边算,连线不能相交, 给出相邻两个格子相连的费用,求最小的总费用,无解输出-1 n,m<=50 保证答案在int范围之内 思路:费用流神仙建模 From https://blog.csdn.net/ahi219/article/details/51454133 把每个格子拆成两个点,然后如下连边: 源点向左边的奇数格子和空格子连容量为1,费用为0的边. 右边的偶数…
题目链接: Coding Contest Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Problem Description A coding contest will be held in this university, in a huge playground. The whole playground would be divided into N blocks,…
Going Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22088   Accepted: 11155 Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertica…
zkw费用流+当前弧优化 var o,v:..] of boolean; f,s,d,dis:..] of longint; next,p,c,w:..] of longint; i,j,k,l,y,t,ss,tt,n,ans,imp,flow:longint; procedure link(i,j,k,l:longint); begin inc(t); next[t]:=d[i]; d[i]:=t; p[t]:=j; c[t]:=k; w[t]:=l; next[-t]:=d[j]; d[j]…
3638: Cf172 k-Maximum Subsequence Sum Time Limit: 50 Sec  Memory Limit: 256 MBSubmit: 174  Solved: 92[Submit][Status][Discuss] Description 给一列数,要求支持操作: 1.修改某个数的值 2.读入l,r,k,询问在[l,r]内选不相交的不超过k个子段,最大的和是多少. Input The first line contains integer n (1 ≤ n …
Machine Programming 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co One remarkable day company "X" received k machines. And they were not simple machines, they were mechanical programmers! This was the last unsuccessful ste…
"Evacuation Plan" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100002 Description The City has a number of municipal buildings and a number of fallout shelters that were build specially to hide municipal workers in case …
Reverse Roads Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93265#problem/E Description ICP city has an express company whose trucks run from the crossing S to the crossing T. The president of the c…
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 1399    Accepted Submission(s): 712 Problem Description There are N cities in our country, and M one-way roads connecting them. Now Li…
Description In a country there are n cities connected by m one way roads. You can paint any of these roads. To paint a road it costs d unit of money where d is the length of that road. Your task is to paint some of the roads so that the painted roads…
Description A prominent microprocessor company has enlisted your help to lay out some interchangeable components(widgets) on some of their computer chips. Each chip’s design is an N × N square of slots. Oneslot can hold a single component, and you ar…
题目链接: http://www.lydsy.com:808/JudgeOnline/problem.php?id=3876 题目大意: 给定一张拓扑图(有向无环图),每条边有边权,每次只能从第一个点出发沿着拓扑图走一条路径,求遍历所有边所需要的最小边权和. 题目思路: [有源汇上下界费用流] Orz两位神犇,以下思路借鉴自 http://hzwer.com/6224.html http://blog.csdn.net/popoqqq/article/details/43024221 建图如下:…
http://poj.org/problem?id=2175 Evacuation Plan Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3256   Accepted: 855   Special Judge Description The City has a number of municipal buildings and a number of fallout shelters that were build…
题意:有N个供应商,M个店主,K种物品.每个供应商对每种物品的的供应量已知,每个店主对每种物品的需求量的已知,从不同的供应商运送不同的货物到不同的店主手上需要不同的花费,又已知从供应商m送第k种货物的单位数量到店主n手上所需的单位花费.供应是否满足需求?如果满足,最小运费是多少? 思路:这题一读完就知道是费用流了,刚开始想着拆点,不过算了一下,把m个供应商拆成m*k个点,n个店主拆成n*k个点,加起来有5000多个点,肯定会超时的,看了网上说每种商品求一次费用流就可以了,就是100个点求50次.…
题目大意:给定nn支球队.第ii支球队已经赢了winiwin_i场.输了loseilose_i场,接下来还有mm场比赛.每一个球队终于的收益为Ci∗x2i+Di∗y2iC_i*x_i^2+D_i*y_i^2,当中xix_i为终于的胜场,yiy_i为终于的负场 求最小化收益 考虑一仅仅球队,其收益与在接下来的比赛中的胜场数关系为: 赢00场 Ci∗win2i+Di∗(di+losei)2C_i*win_i^2+D_i*(d_i+lose_i)^2 赢11场 Ci∗(wini+1)2+Di∗(di+…
题面 On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little man, you need to pay a $1 travel fee for every step he moves,…
[LOJ#3097][SNOI2019]通信(费用流) 题面 LOJ 题解 暴力就直接连\(O(n^2)\)条边. 然后分治/主席树优化连边就行了. 抄zsy代码,zsy代码是真的短 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; #define ll long long #define MAX 50000 const int inf=1e9; inline int…
最大流/ISAP 话说ISAP是真快...(大多数情况)吊打dinic,而且还好写... 大概思路就是: 在dinic的基础上, 动态修改层数, 如果终点层数 \(>\) 点数, break. 暂时并不知道isap有没有可能被卡. 应该不会 const int ninf=(int)1e9+500,psz=(int)450,esz=(int)1e5+50; //network flow struct te{int t,pr,fl;}edge[esz*2]; int hd[psz],pe=1,np,…
P3440 [POI2006]SZK-Schools 每所学校$i$开一个点,$link(S,i,1,0)$ 每个编号$j$开一个点,$link(i,T,1,0)$ 蓝后学校向编号连边,$link(i,j,1,val)$ 最后跑一遍费用流 如果没有满流就是$NIE$ 否则就是最小代价了 #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace s…
题目描述 给一列数,要求支持操作: 1.修改某个数的值 2.读入l,r,k,询问在[l,r]内选不相交的不超过k个子段,最大的和是多少. 输入 The first line contains integer n (1 ≤ n ≤ 105), showing how many numbers the sequence has. The next line contains n integers a1, a2, ..., an (|ai| ≤ 500). The third line contain…
Mining Station on the Sea Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3565    Accepted Submission(s): 1108 Problem Description The ocean is a treasure house of resources and the development…
P2053 [SCOI2007]修车 顾客平均等待的最小时间$=$等待总时间$/n$ 考虑只有1个技术人员时,$n$辆车等待总时间 $A_1+(A_1+A_2)+(A_1+A_2+A_3)+...+\sum_{i=1}^{n}A_i$ 发现第$k$个修第$i$辆车的代价为$A_i*(n-k+1)$ 为了方便我们把它换个形式 倒着第$k$个修第$i$辆车的代价为$A_i*k$ 想到可以用费用流解决 于是我们可以把 第$i$个人倒着第$k$个修第$j$辆车 当成一个点 车代表的点向该点连一条边 流量…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5988 题目大意: 给定n个点,m条有向边,每个点是一个吃饭的地方,每个人一盒饭.每个点有S个人,有B盒饭.每条边只能被走c次,每条边上都有电线,第一个人通过的时候,不会破坏电线,从第二个人开始,每次都有概率p破坏掉电线.使得每个人都能吃饭,求最小破坏电线的概率. 解题思路: 题目要求我们求最小破坏电线的概率,就是一个最小乘积问题,加上log可以将其转变为加法,那样就可以使用费用刘来解决了. 按以下方…
题目描述: Life is a journey, and the road we travel has twists and turns, which sometimes lead us to unexpected places and unexpected people. Now our journey of Dalian ends. To be carefully considered are the following questions. Next month in Xian, an e…
"Shortest" pair of paths Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1589 Accepted: 708 Description A chemical company has an unusual shortest path problem. There are N depots (vertices) where chemicals can be stored. There are M…
Problem I. Plugs and Sockets 题目连接: http://www.codeforces.com/gym/100253 Description The Berland Regional Contest will be held in the main hall of the Berland State University. The university has a real international status. That's why the power socke…
累了就要写题解,近期总是被虐到没脾气. 来回最短路问题貌似也能够用DP来搞.只是拿费用流还是非常方便的. 能够转化成求满流为2 的最小花费.一般做法为拆点,对于 i 拆为2*i 和 2*i+1.然后连一条流量为1(花费依据题意来定) 的边来控制每一个点仅仅能通过一次. 额外加入source和sink来控制满流为2. 代码都雷同,以HDU3376为例. #include <algorithm> #include <iostream> #include <cstring>…
Coding Contest http://acm.hdu.edu.cn/showproblem.php?pid=5988 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 5337    Accepted Submission(s): 1256 Problem Description A coding contest will be he…
There will be several test cases in the input. Each test case will begin with a line with three integers: N A B Where N is the number of teams (1N1, 000), and A and B are the number of balloons in rooms A and B, respectively (0A, B10, 000). On each o…
多校联赛第一场(hdu4862) Jump Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 644    Accepted Submission(s): 275 Problem Description There are n*m grids, each grid contains a number, ranging from 0-9.…