博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 1129 Channel Allocation
阅读量:6609 次
发布时间:2019-06-24

本文共 3119 字,大约阅读时间需要 10 分钟。

                                                                                Channel Allocation

Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 6071   Accepted: 3108

Description

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.

Input

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.
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
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.

Output

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.

Sample Input

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

Sample Output

1 channel needed. 3 channels needed. 4 channels needed.

Source

 

1 #include 
2 #include
3 #include
4 #include
5 6 using namespace std; 7 struct Node{ 8 int data[27]; 9 int rear; 10 }q[27]; 11 12 int n; 13 14 int data[27]; 15 int check(int x,int i) 16 {
int j; 17 for(j=0;j
n) 33 if(k
=mount) 36 return 0; 37 38 39 if(x>n) 40 { for(i=1;i<=n;i++) 41 if(visited[i]) 42 sum++; 43 //cout<
<
>n,n) 70 { char a,b,c; 71 72 memset(data,0,sizeof(data)); 73 memset(visited,0,sizeof(visited)); 74 75 mount=45; 76 77 for(i=1;i<=n;i++) 78 {cin>>a; 79 cin>>c; 80 q[a-'A'+1].rear=0; 81 while(1) 82 { 83 b=getchar(); 84 if(b==10) 85 break; 86 q[a-'A'+1].data[q[a-'A'+1].rear++]=(int)(b-'A'+1); 87 88 } 89 } 90 dfs(1); 91 cout<

转载于:https://www.cnblogs.com/zjushuiping/archive/2012/05/31/2527965.html

你可能感兴趣的文章
Java多线程总结之线程安全队列Queue
查看>>
百度编辑器 Ueditor 下拉处增加字体
查看>>
WPF 虚拟化 VirtualizingWrapPanel 和 VirtualLizingTilePanel
查看>>
Redis快速入门
查看>>
nodejs 相关
查看>>
Diffie-Hellman密钥交换算法
查看>>
复制表结构和数据SQL语句
查看>>
JavaScript onkeydown事件入门实例(键盘某个按键被按下)
查看>>
免费开源的DotNet二维码操作组件ThoughtWorks.QRCode(.NET组件介绍之四)
查看>>
Unity进阶技巧 - 动态创建UGUI
查看>>
【简单易懂的AMV图文教程-2】VEGAS基础进阶——认识关键帧
查看>>
使用css打造形形色色的形状!
查看>>
Spring切面处理
查看>>
浅谈CPU和GPU的区别
查看>>
开源大数据利器汇总
查看>>
从知名外企到创业公司做CTO是一种怎样的体验?
查看>>
Oracle 表空间和用户权限管理【转】
查看>>
如何安装nginx第三方模块
查看>>
LXC学习实践(3)快速体验第一个容器
查看>>
转:winform_webApiSelfHost及 OWIN WebAPI Service
查看>>