UVA Bandwidth
题目例如以下:
| Bandwidth |
Given a graph (V,E) where V is a set of nodes and E is a set of arcsin VxV, and an
ordering on the elements in V, then the bandwidth of a node
v is defined as the maximum distance in theordering between v and any node to which it is connected in thegraph. The bandwidth of the ordering is then defined as the maximum ofthe individual bandwidths. For example, consider the following graph:

This can be ordered in many ways, two of which are illustrated below:

For these orderings, the bandwidths of the nodes (in order) are 6, 6,1, 4, 1, 1, 6, 6 giving an ordering bandwidth of 6, and 5, 3, 1, 4, 3,5, 1, 4 giving an ordering bandwidth of 5.
Write a program that will find the ordering of a graph that minimisesthe bandwidth.
Input
Input will consist of a series of graphs. Each graph will appear on aline by itself. The entire file will be terminated by a lineconsisting of a single
#. For each graph, the input will consist ofa series of records separated by `;'. Each record will consist of anode name (a single upper case character in the the range `A' to `Z'),followed by a `:' and at least one of its neighbours. The graph willcontain
no more than 8 nodes.
Output
Output will consist of one line for each graph, listing the orderingof the nodes followed by an arrow (->) and the bandwidth for thatordering. All items must be separated from their neighbours by exactlyone space. If more than one ordering produces the same
bandwidth, thenchoose the smallest in lexicographic ordering, that is the one thatwould appear first in an alphabetic listing.
Sample input
A:FB;B:GC;D:GC;F:AGH;E:HD
#
Sample output
A B C F G D H E -> 3
给一个图,求出使图的带宽为最小值的节点的排列,带宽指每一个节点的与相邻节点在排列中距离的最大值。图的带宽是节点带宽的最大值。因为节点最多仅仅有八个,直接枚举全排列就可以。假设节点数较多应该剪枝,但本题显然不须要。
AC的代码例如以下:
UVA Bandwidth的更多相关文章
- uva 140 bandwidth (好题) ——yhx
Bandwidth Given a graph (V,E) where V is a set of nodes and E is a set of arcs in VxV, and an orde ...
- UVa OJ 140 - Bandwidth (带宽)
Time limit: 3.000 seconds限时3.000秒 Problem问题 Given a graph (V,E) where V is a set of nodes and E is a ...
- UVA 820 Internet Bandwidth 因特网宽带(无向图,最大流,常规)
题意:给一个无向图,每条边上都有容量的限制,要求求出给定起点和终点的最大流. 思路:每条无向边就得拆成2条,每条还得有反向边,所以共4条.源点汇点已经给出,所以不用建了.直接在图上跑最大流就可以了. ...
- UVa 140 (枚举排列) Bandwidth
题意较复杂,请参见原题=_=|| 没什么好说的,直接枚举每个排列就好了,然后记录最小带宽,以及对应的最佳排列. STL里的next_permutation函数真是好用. 比较蛋疼的就是题目的输入了.. ...
- UVA 820 Internet Bandwidth
题意: 给出双向图,求给出两点的流通总流量. 分析: 网络流中的增广路算法. 代码: #include <iostream>#include <cstring>#include ...
- UVa 820 Internet Bandwidth (裸板网络流)
题意:有一个计算机网络,输入节点数n,输入网络流源点和汇点src,des,再输入双向边数m.给出m条边的负载,求最大流. 析:直接上网络流的最大流. 代码如下: #pragma comment(lin ...
- UVA - 820 Internet Bandwidth(最大流模板题)
题目: 思路: 直接套最大流的模板就OK了,注意一下输出的格式. 代码: #include <bits/stdc++.h> #define inf 0x3f3f3f3f #define M ...
- UVa 140 Bandwidth【枚举排列】
题意:给出n个节点的图,和一个节点的排列,定义节点i的带宽b[i]为i和其相邻节点在排列中的最远的距离,所有的b[i]的最大值为这个图的带宽,给一个图,求出带宽最小的节点排列 看的紫书,紫书上说得很详 ...
- UVA - 820 Internet Bandwidth (因特网带宽)(最大流)
题意:给出所有计算机之间的路径和路径容量后,求出两个给定结点之间的流通总容量.(假设路径是双向的,且两方向流动的容量相同) 分析:裸最大流.标号从1开始,初始化的时候注意. #pragma comme ...
随机推荐
- SpringBoot与Dubbo整合-项目搭建
本章节建立生产者和消费者来演示dubbo的demo 生产者:springboot-dubbo-provider 和 消费者:springboot-dubbo-consumer 工程配置详解 Apach ...
- 分享一个表格插入和删除编辑功能用jQuery实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Oracle primary key&foreign key
--主键 alter table tablename1 add constraint pk_tablename1 primary key(column1);--增加数据表1的主键column1,如果是 ...
- HDU 2689 Tree
Tree Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- Json应用案例
Json应用案例之FastJson 这几天在网上找关于Json的一些案例,无意当中找到了一个我个人感觉比较好的就是阿里巴巴工程师写的FastJson. package com.jerehedu.f ...
- Windows学习总结(2)——30+ Windows命令提示符快捷键汇总
即便你平时经常用到 Windows 命令提示符,可能也会对本文将提到的快捷键数量感到惊讶.其实我们可以使用快捷键来简化命令提示符中的选择操作,或对文本进行重复操作,下面我们会列出完整列表. 大家都知道 ...
- Cocos2d-x 之大牛看法
(未完毕) cocos2d-x并非一个适合网游client(mmo)的游戏引擎.越是大型游戏,这个小引擎就越无法驾驭(尽管它很受欢迎). 之前我在原来的公司使用的是自主研发的C3引擎,已经对外开放(尚 ...
- js12---闭包,原型,继承
<html> <body> <script type="text/javascript"> //闭包实现了函数层面多个子函数共享父类函数的属性. ...
- Android开发经验之获取画在画布上的字符串长度、宽度(所占像素宽度)
Android中获取字符串长度.宽度(所占像素宽度) 计算出当前绘制出来的字符串有多宽,可以这么来! 方法1: Paint paint = new Paint(); Rect rect = new R ...
- HTML实体与网页编码(汉字转化为了html实体) .
http://blog.csdn.net/f438952359/article/details/7481267 HTML实体与网页编码(汉字转化为了html实体) . htmlencodingfunc ...