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 ...
随机推荐
- 【单调队列】【动态规划】bzoj3831 [Poi2014]Little Bird
f(i)=min{f(j)+(D(j)<=D(i))} (max(1,i-k)<=j<=i) 有两个变量,很难用单调队列,但是(引用): 如果fi<fj,i一定比j优秀.因为如 ...
- [CF877F]Ann and Books
题目大意: 有$n(n\le10^5)$个数$w_{1\sim n}(|w_i|\le10^9)$,并给定一个数$k(|k|\le10^9)$.$q(q\le10^5)$次询问,每次询问区间$[l,r ...
- NPOI读取Excel2003,2007
using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Lin ...
- Scala高手实战****第18课:Scala偏函数、异常、Lazy值编码实战及Spark源码鉴赏
本篇文章主要讲述Scala函数式编程之偏函数,异常,及Lazy 第一部分:偏函数 偏函数:当函数有多个参数,而在使用该函数时不想提供所有参数(比如函数有3个参数),只提供0~2个参数,此时得到的函数便 ...
- C# 6.0语法新特性体验(二)
之前我在文章通过Roslyn体验C# 6.0的新语法中介绍了一些C# 6.0的语法特性,现在随着Visual Studio 14 CTP3的发布,又陆续可以体验一些新的特性了,这里简单的介绍一下之前没 ...
- 《西安交大电路》(Principles of Electrical Circuits) 学习笔记
内容简介:电路分析是电子类专业的第一门基础课. 电路理论包括电路分析和电路综合两大方面内容.电路分析的主要内容是指在给定电路结构.元件参数的条件下,求取由输入(激励)所产生的输出(响应):电路综合则主 ...
- 【java】子类可以通过调用父类的public方法调用父类的private方法,为什么?
代码1: 打印结果: 代码2: 运行结果: 问题: 代码1中super是父类自己调用自己的add()方法,并在add()方法中调用了私有的del()方法,那为什么打印出来的this是子类? 代码2中t ...
- jquery获取下拉列表的值和显示内容的方法
页面的下拉列表: 选择时间段: <select name="timespan" id="timespan" class="Wdate" ...
- ylbtech-LanguageSamples-Arrays(数组)
ylbtech-Microsoft-CSharpSamples:ylbtech-LanguageSamples-Arrays(数组) 1.A,示例(Sample) 返回顶部 “数组”示例 本示例介绍并 ...
- ubuntu查看系统版本
1.查看文件信息,包含32-bit就是32位,包含64-bit就是64位 root@HDController:/home/nulige/tools# uname -a Linux HDControll ...