140-bandwidth
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=108&page=show_ problem&problem=76
Given a graph (v,e) where V is a set of nodes and E are a set of arcs in VXV, and anordering on the elements in V, then the Bandwidth of a nodev is defined as the maximum distance into the ordering betweenv and any node to which it are connected in The graph. The bandwidth of the ordering is then defined as the maximum of the individual. For example, consider the following graph:
This can is ordered in many ways, two of which are illustrated below:
For this orderings, the bandwidths of the nodes (in order) are 6, 6, 1, 4, 1, 1, 6, 6 giving a ordering bandwidth of 6, and 5, 3, 1, 4, 3, 5, 1, 4 giving an ordering bandwidth of 5.
Write a program that'll find the ordering of a graph that minimises the bandwidth.
Input
Input would consist of a series of graphs. Each graph would appear on a line by itself. The entire file is terminated by a line consisting of a single#. For each graph, the input would consist of a series of records separated by '; Each record would consist of a node name (a single upper case character in the "a ' to ' Z"), followed by a ': ' and At least one of its neighbours. The graph would contain no more than 8 nodes.
Output
Output would consist of one line for each graph, listing the ordering of the nodes followed by a arrow (->) and the ban Dwidth for that ordering. All items must is separated from their neighbours by exactly one space. If more than one ordering produces the same bandwidth, then choose the smallest in lexicographic ordering, which is the one That would appear the 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
The enumeration is all arranged and cut off when encountering Nowmin > _min.