HNU 13411 Reverse a Road II(最大流+BFS)经典
| Reverse a Road II |
| Time Limit: 10000ms, Special Time Limit:25000ms, Memory Limit:65536KB |
| Total submit users: 10, Accepted users: 6 |
| Problem 13411 : No special judgement |
| Problem description |
|
JAG Kingdom is a strange kingdom such that its N cities are connected only by one-way roads. The N cities are numbered 1 through N. ICPC (International Characteristic Product Corporation) transports its products from the factory at the city S to the storehouse |
| Input |
|
The input consists of multiple datasets. The number of dataset is no more than 100. |
| Output |
|
For each dataset, output two integers separated by a single space in a line as follows: If reversal of a single road improves the current maximum number of trucks for daily transports, the first output integer is the new maximum after reversal of a road, |
| Sample Input |
4 4 1 4 |
| Sample Output |
1 2 |
| Problem Source |
|
JAG Practice Contest for ACM-ICPC Asia Regional 2014 题意:给一个有向图,n个点,m条边,起点S ,终点T。现有非常多个机器人要从S走到T,每条边仅仅能走一个机器人,现要能够改一条边的方向,问最多有多少个机器人能够从S走到T。而且有多少种改法。(假设没有改变边的方向,则改法为0。) 解题:如要没有加条件:能够改一条边。那么这题就是找最多有多少条路要以从起点S走到T。建图:每条有向边的边权为1,用最大流跑一次。那么如今要改一条边的方向:假设要更改的边是走过的边,那么不会使走法添加,有能够还使路的条数降低,所以改的边一定不是满流的边(即走过的边)。如今要改变一条不在走过的边< u , v >变成<v , u>,使得能够增流,那么仅仅要从S沿着没有走过的边到 v 。再从u沿着没有走过的边 到 T。这样就能够使得路的条数增多。 那么这样我们就能够用BFS标记 SF[] 能从S点沿着最大流每条边的残流量>0的边走到的一些点V,再标记 最后的最多机器人数ans = maxflow + k>0 ? 1 : 0 。 #include<stdio.h> |
HNU 13411 Reverse a Road II(最大流+BFS)经典的更多相关文章
- 【leetcode】Reverse Linked List II
Reverse Linked List II Reverse a linked list from position m to n. Do it in-place and in one-pass. F ...
- 14. Reverse Linked List II
Reverse Linked List II Reverse a linked list from position m to n. Do it in-place and in one-pass. F ...
- 【原创】Leetcode -- Reverse Linked List II -- 代码随笔(备忘)
题目:Reverse Linked List II 题意:Reverse a linked list from position m to n. Do it in-place and in one-p ...
- 92. Reverse Linked List II
题目: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1- ...
- lc面试准备:Reverse Linked List II
1 题目 Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1 ...
- 【LeetCode练习题】Reverse Linked List II
Reverse Linked List II Reverse a linked list from position m to n. Do it in-place and in one-pass. F ...
- [Linked List]Reverse Linked List,Reverse Linked List II
一.Reverse Linked List (M) Reverse Linked List II (M) Binary Tree Upside Down (E) Palindrome Linked ...
- LeetCode之“链表”:Reverse Linked List && Reverse Linked List II
1. Reverse Linked List 题目链接 题目要求: Reverse a singly linked list. Hint: A linked list can be reversed ...
- 4990: [Usaco2017 Feb]Why Did the Cow Cross the Road II 线段树维护dp
题目 4990: [Usaco2017 Feb]Why Did the Cow Cross the Road II 链接 http://www.lydsy.com/JudgeOnline/proble ...
随机推荐
- POJ 2315:Football Game(博弈论)
[题目链接] http://poj.org/problem?id=2315 [题目大意] 两名球员轮流从N个球中挑出不多于M个射门,每个球半径都是R,离球门S. 每次只能踢出L以内的距离.进最后一个球 ...
- 【字符串哈希】bzoj3098 Hash Killer II
教育我们做Rabin-Karp的时候一定要把模数取大?还是上溢好了. #include<cstdio> #include<cstdlib> using namespace st ...
- Java读取文本文件
try { // 防止文件建立或读取失败,用catch捕捉错误并打印,也可以throw StringBuilder stringBuilder = new StringBuilder(); // 读入 ...
- cssz中<a>标签鼠标选中去除选中边框
IE: <a href="#" hidefocus="true"></a> 非IE: a:focus { outline:none; } ...
- GetAdaptersInfo & GetAdaptersAddresses
I use GetAdaptersInfo to get MAC addresses of interfaces. GetAdaptersInfo exist on old and new ver ...
- JavaScript之链式结构序列化1
一.概述 在JavaScript中,链式模式代码,太多太多,如下: if_else: if(...){ //TODO }else if(...){ //TODO }else{ //TODO } swi ...
- 使用Ant项目打包
一.前沿 前段时间公司为了做一个新闻发布系统,就使用了开源的JEECMS系统,(非人类啊,泪~~~),项目不是maven构建的,项目的打包部署非常的麻烦,没办法只能使用Ant,Ant是比较古老的打包部 ...
- html5:localStorage储存
实例:刷新值会增长,关掉浏览器,再打开,值会在原基础上增长 if(localStorage.pagecount){ localStorage.pagecount=Number(localStorage ...
- ArrayAdapter、SimpleAdapter和BaseAdapter示例代码
import android.content.Context; import android.util.Pair; import android.view.View; import android.v ...
- 64位的centos6.9的vnc-sever的安装及桌面环境安装
1.VNC (Virtual Network Computer)是虚拟网络计算机的缩写.VNC 是在基于 UNIX 和 Linux 操作系统的免费的开源软件,远程控制能力强大,高效实用,其性能可以和 ...