题意是有若干个接收器,给出每个接收器的相邻接收器。相邻的接收器不能使用同一信号频道。问所需要的信号频道数。

求该无向图的极大团。

 #include<iostream>
#include<cstring>
#include<string>
#define maxn 30
using namespace std;
int stack[maxn],map[maxn][maxn];
int n,cn,bestn;
void dfs(int x){
if (x>n){
bestn=max(cn,bestn);
return ;
}
int flag=;
for (int i=;i<cn;i++){
if (!map[stack[i]][x]){
flag=;
break;
}
}
if (flag){
stack[cn++]=x;
dfs(x+);
cn--;
}
if (cn+n-x>bestn){
dfs(x+);
}
}
int main(){
string S;
while (cin >> n && n){
memset(map,,sizeof(map));
for (int id=;id<n;id++){
cin >> S;
int pre=S[]-'A';
int len=S.length();
for (int i=;i<len;i++){
int res=S[i]-'A';
map[pre][res]=map[res][pre]=;
}
}
cn=bestn=;
memset(stack,,sizeof(stack));
dfs();
if (bestn==) cout << "1 channel needed.\n";
else cout << bestn << " channels needed.\n";
}
return ;
}

hdoj1373 Channel Allocation(极大团)的更多相关文章

  1. poj1129 Channel Allocation

    Channel Allocation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14361   Accepted: 73 ...

  2. 迭代加深搜索 POJ 1129 Channel Allocation

    POJ 1129 Channel Allocation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14191   Acc ...

  3. Channel Allocation

    Channel Allocation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13231 Accepted: 6774 D ...

  4. poj1129 Channel Allocation(染色问题)

    题目链接:poj1129 Channel Allocation 题意:要求相邻中继器必须使用不同的频道,求需要使用的频道的最少数目. 题解:就是求图的色数,这里采用求图的色数的近似有效算法——顺序着色 ...

  5. Channel Allocation (poj 1129 dfs)

    Language: Default Channel Allocation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12 ...

  6. Channel Allocation(DFS)

    Channel Allocation Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) ...

  7. POJ 2989 All Friends 极大团计数

    POJ 2989 题意:给定一个无向图(节点数小于128)求极大团(不包含在更大的团中)的总数. 对最大团,极大团不熟悉的,建议先阅读最大团搜索问题 ZOJ 1492 再来看本题. 本题数据有限,可以 ...

  8. All Friends 极大团

    搞懂了什么是团  什么是极大团  什么是最大团 极大团就是  不是任何团的真子集  最大团就是点数最多的极大团 这题就是求极大团的个数 用bk算法 #include <iostream> ...

  9. POJ 1129 Channel Allocation(DFS)

    Channel Allocation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13173   Accepted: 67 ...

随机推荐

  1. PHP在win7安装Phalcon框架

    我的环境是64位的 Win7. 安装 Phalcon 也极其简单,只需要下载一个文件(php_phalcon.dll), 要以 phpinfo() 里面“Architecture”属性为准! 下载地址 ...

  2. Boolean.getBoolean用法

    相信很多人被Boolean.getBoolean(String name)欺骗过,想当然的认为它是将"true"或者"false"转换为Boolean类型的AP ...

  3. [Meteor] meteor project structure

  4. OSGi 系列(三)之 bundle 事件监听

    OSGi 系列(三)之 bundle 事件监听 bundle 的事件监听是在 bundle 生命周期的不同状态相互转换时,OSGi 框架会发出各种不同的事件供事先注册好的事件监听器处理. 1. 事件监 ...

  5. html5移动开发。

    禁止滚动 $('#idl').bind("touchmove",function(e){ e.preventDefault(); }); 图片居中 (因为图片比较特别,所以需要在外 ...

  6. python之BeautifulSoup模块

    # 名称修改(bs4) from bs4 import BeautifulSoup 帮助文档 Beautiful Soup parses a (possibly invalid) XML or HTM ...

  7. 2018.08.02 洛谷P3355 骑士共存问题(最小割)

    传送门 这题让我联想到一道叫做方格取数问题的题,如果想使摆的更多,就要使不能摆的更少,因此根据骑士的限制条件建图,求出至少有多少骑士不能摆,减一减就行了. 代码: #include<bits/s ...

  8. cordova 选择图片并上传到服务器

    js navigator.camera.getPicture(function(imageURI){ var url=apiUrl+"/upload.aspx"; //alert( ...

  9. 在centos7.1上安装systemd

    1.检查本地systemd的版本 [admin@localhost ~]$ systemctl --version          systemd 208   +PAM +LIBWRAP +AUDI ...

  10. Java实现浏览器端大文件分片上传

    版权所有 2009-2018荆门泽优软件有限公司 保留所有权利 官方网站:http://www.ncmem.com/ 产品首页:http://www.ncmem.com/webapp/up6.2/in ...