2.5基本算法之搜索题翻译

Channel Allocation【信道分配】

 1000ms  65536K

描述:

When a radio station is broadcasting over a very large area, repeaters are used to retransmit the signal so that every receiver has a strong signal. However, the channels used by each repeater must be carefully chosen so that nearby repeaters do not interfere with one another. This condition is satisfied if adjacent repeaters use different channels.

Since the radio frequency spectrum is a precious resource, the number of channels required by a given network of repeaters should be minimised. You have to write a program that reads in a description of a repeater network and determines the minimum number of channels required.

【当一个广播台在一个非常大的区域内广播,转发器被用来转播信号以便每个接收者能有很强的信号,然而每个转发器的频道选择必须非常小心,避免附近的转发器受其它干扰。如果邻近的转发器使用不同的频道将满足上述情况。因为广播顺畅范围是一个非常宝贵的资源,所以给定的网络转发器在需要频道的数量应该保证最小。你需要编写一个程序读入转发器网络,并且决定所需频道数最小数量。】

输入:

The input consists of a number of maps of repeater networks. Each map begins with a line containing the number of repeaters. This is between 1 and 26, and the repeaters are referred to by consecutive upper-case letters of the alphabet starting with A. For example, ten repeaters would have the names A,B,C,...,I and J. A network with zero repeaters indicates the end of input.
【输入包含许多转发器网络图,每张地图以转发器数量为一行开始。这个范围在1-26,而这些转发器以连续不断的大写字母ABC...命名。举个例子,十台转发器将有编号ABC...I至J。若一个网络图没有转发器,则输入停止。】
Following the number of repeaters is a list of adjacency relationships. Each line has the form:

【接下来则是邻近转发器数量关系图,每行格式如下:】
A:BCDH

which indicates that the repeaters B, C, D and H are adjacent to the repeater A. The first line describes those adjacent to repeater A, the second those adjacent to B, and so on for all of the repeaters. If a repeater is not adjacent to any other, its line has the form
【BCDH转发器是转发器A的邻近转发器,第一行描述转发器A的邻近转发器,第二行则是转发器B的邻近转发器,以此类推,如果一个转发器没有邻近转发器,则有如下形式。】
A:

The repeaters are listed in alphabetical order.
【转发器编号按字母表顺序排列】
Note that the adjacency is a symmetric relationship; if A is adjacent to B, then B is necessarily adjacent to A. Also, since the repeaters lie in a plane, the graph formed by connecting adjacent repeaters does not have any line segments that cross.

【注意转发器的邻近性是对称的,如果A与B邻近,那么B必然与A邻近,并且因为转发器的排列是在同一个平面内,形成的图形连接相邻转发器没有任何线段交叉】

输出:

For each map (except the final one with no repeaters), print a line containing the minumum number of channels needed so that no adjacent channels interfere. The sample output shows the format of this line. Take care that channels is in the singular form when only one channel is required.

【对于每张图(除了最后不含频道的转发器),输出一行所需最少频道数量,下列为样本数据,注意当只需一个频道,频道数是单数形式】

样例输入:

2
A:
B:
4
A:BC
B:ACD
C:ABD
D:BC
4
A:BCD
B:ACD
C:ABD
D:ABC
0

样例输出:

1 channel needed.
3 channels needed.
4 channels needed. 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值