UVA Bandwidth
来源:互联网 发布:高速公路的数据 编辑:程序博客网 时间:2024/04/30 06:20
Bandwidth
Given a graph (V,E) where V is a set of nodes and E is a set of arcsin VxV, and anordering 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
- Bandwidth UVA
- Bandwidth(UVA
- Bandwidth UVA
- UVa 140 - Bandwidth
- uva 140 - Bandwidth
- UVa 140 - Bandwidth
- uva 140 - Bandwidth
- UVa 140 - Bandwidth
- UVA 140 - Bandwidth
- UVa 140 - Bandwidth
- UVA 140 Bandwidth
- uva 140 Bandwidth
- uva 140 Bandwidth
- UVa:140 Bandwidth
- UVa 140 - Bandwidth
- uva 140 - Bandwidth
- UVa 140 Bandwidth
- 无监督特征学习——Unsupervised feature learning and deep learning
- 新的开始
- apache phoenix简单部署测试
- Extjs4 Combobox 联动始终出现loading错误的解决办法
- 获取xml信息并转为string
- UVA Bandwidth
- cocos2dx3.0 制作音效开关
- Objective C 快速入门学习三
- 从事SEO以来,你最讨厌的是什么?
- JPA API(四)
- ideaIU_13.1.3安装图解。
- 如何让思维具有独创性、彻底性、观念之间逻辑的严密性,以及从全局观点看问题?
- Java中实现简单的三大排序——冒泡、选择、插入
- Echars 地图展示