HDU 2485 Destroying the bus stations】的更多相关文章

Description Gabiluso is one of the greatest spies in his country. Now he’s trying to complete an “impossible” mission ----- to make it slow for the army of City Colugu to reach the airport. City Colugu has n bus stations and m roads. Each road connec…
Problem Description Gabiluso is one of the greatest spies in his country. Now he's trying to complete an "impossible" mission ----- to make it slow for the army of City Colugu to reach the airport. City Colugu has n bus stations and m roads. Eac…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2485 题意:给你n个点,m条相连的边,问你最少去掉几个点使从1到n最小路径>=k,其中不能去掉1,n两个点. 题解:这个题目可以用最小流解决,也可以用IDA*  +  BFS解决. AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include…
http://acm.hdu.edu.cn/showproblem.php?pid=2485 题意: 现在要从起点1到终点n,途中有多个车站,每经过一个车站为1时间,现在要在k时间内到达终点,问至少要破坏多少个车站. 思路: 把每个点拆分为两个点,容量为1,费用为0.之后相邻的车站连边,容量为INF,费用为1,表示经过一个车站需要1时间. 这样一来,跑一遍费用流计算出在费用不大于k的情况下的最大流,也就是最小割,即至少要破坏的车站数. 在网络中寻求关于f的最小费用增广路,就等价于在伴随网络中寻求…
2015 ACM / ICPC 北京站 热身赛 C题 #include<cstdio> #include<cstring> #include<cmath> #include<queue> #include<vector> #include<algorithm> using namespace std; const int INF=0x7FFFFFFF; +;//点的数量 int n,m,k; +],v[+]; int dis1[max…
题意: 最少需要几个点才能使得有向图中1->n的距离大于k. 分析: 删除某一点的以后,与它相连的所有边都不存在了,相当于点的容量为1.但是在网络流中我们只能直接限制边的容量.所以需要拆点来完成对的点容量的限制.对于边i -> j,先建边i ->i',再建i'->j.i ->i'只能建一次,容量为1,费用为0.i'->j的容量是INF.此题中因为已经有源点,所以源点(1)不能限制容量. #include<iostream> #include<cstdi…
Destroying the bus stations                                                                                     Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)                                                       …
Destroying the bus stations Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1832   Accepted: 595 Description Gabiluso is one of the greatest spies in his country. Now he's trying to complete an “impossible” mission - to make it slow for…
题意: 就是求最小割点 解析: 正向一遍spfa 反向一遍spfa  然后遍历每一条边,对于当前边 如果dis1[u] + dis2[v] + 1 <= k 那么就把这条边加入到网络流图中, 每个点拆点 边权为1 跑最大流即可 代码还是改的那一题... #include <iostream> #include <cstring> #include <cstdio> #include <queue> #include <cmath> #inc…
题目:给出一个图,问最少删除多少个点,使得从点1到点n经过的点数超过k个. 分析: 上网搜了一下,发现很多人用网络流做的,发现我不会.再后来看到这篇说网络流的做法是错的,囧. 后来发现点数有点少,直接上爆搜.每次搜索前先跑一遍最短路,判断是否满足,如果满足更新答案,退出. 否则,在求最短路时记录一下路径,然后枚举删除最短路上的点,继续搜. 第一次写时,记录路径用的是全局变量,每次搜下一层的时候就会变,发现居然也A了... 我试了一下,发现n不会等于1... #include <set> #in…