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 ...
随机推荐
- [CF441E]Valera and Number
题意:给定$x,k,p$和一份伪代码,伪代码大致是循环$k$次,每次有$p\%$的概率把$x$乘$2$,有$(100-p)\%$的概率把$x$加$1$,问最后在二进制下$x$的末尾期望$0$个数 鸽了 ...
- Android中的动态字符串的处理
1.效果显示 2. MainAcitivity.java package com.example.app2; import android.support.v7.app.AppCompatActivi ...
- JAVA call graphs JAVA调用图
https://github.com/gousiosg/java-callgraph Programs for producing static and dynamic (runtime) call ...
- 如何垂直居中元素(浮动元素&居中一个<img>)?
1.如何居中一个浮动元素? 方法一:已知元素的高度 <!DOCTYPE html> <html lang="en"> <head> < ...
- Tempter of the Bone——DFS(王道)
Problem Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, ...
- Accessing Report Server using Report Server Web Service - Microsoft SQL Server 2008R2
Today I am going to write about how to access SQL Server Report Server through Report Server Web ser ...
- PostgreSQL数据库的安装与配置
项目中要用PostgreSQL,所以专门学习了一下如何安装和调试postgresql,此博文用来记录自己的安装和调试过程,安装环境是centos7. 首先尝试了yum安装,因为毕竟yum安装简单粗暴, ...
- Idea闪退问题-内存不能给太大
Idea闪退问题-内存不能给太大 学习了:https://blog.csdn.net/qq_17776287/article/details/77529455 学习了:https://blog.csd ...
- 复选框input:checkbox
复选框 CreateTime--2017年6月5日14:04:55Author:Marydon 五.复选框 (一)语法 <input type="checkbox" /& ...
- 为每一个应用程序池单独设置aspnet.config配置文件
ASP.NET2.0之后的版本号就在各Framework的根文件夹下提供了一个aspnet.config文件.这个文件用来配置全局的一些信息,可是一直以来我们都没有怎么用过. ASP.NET4.0之后 ...