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

求该无向图的极大团。

 #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. db2 统计信息 runstats

    1.runstats的语法:runstats on table [模式名].[表名] with distribution and detailed indexes all注意:你可以在所有列上,或者仅 ...

  2. 神奇的照片修复术,这才是 PS 的正确打开方式!

    蒲公英种子从远处飘回 聚成伞的模样 太阳从西边升起 落向东方 运动员回到起跑线上 轰鸣的火车退回家乡 雪花纷飞 飘向天际 我沉入梦乡 你还在我身旁 ——公益广告 大概只有时光倒流,我们才能回到那些每天 ...

  3. php调用C#写的dll包

    1.转到需要注册的dll路径下 2.输入regasm命令+文件名 3问题解决

  4. php用get方式传json数据 变成null了

    $data = I('param.data'); $data=stripslashes(html_entity_decode($data));//$data为传过去的json字符串

  5. spring 3 mvc 的 @ResponseBody返回数据中文乱码

    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter&q ...

  6. TextView等组件的LayoutParams不能随便用,不然组件不显示

    TableLayout.LayoutParams lpRow = new TableLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTEN ...

  7. try-catch+thows异常范围说明

    方式一: CatalogPO deleteTarget = null; /** 查询是否存在 **/ deleteTarget = catalogMapper.findByCatalogId(cata ...

  8. UVa 11134 Fabled Rooks (贪心+问题分解)

    题意:在一个n*n的棋盘上放n个车,让它们不互相攻击,并且第i辆车在给定的小矩形内. 析:说实话,一看这个题真是没思路,后来看了分析,原来这个列和行是没有任何关系的,我们可以分开看, 把它变成两个一维 ...

  9. Ubuntu安装教程(双系统)

    经常要重装还不如写个安装教程省的每次都要查 Ubuntu安装教程: win7下安装Linux实现双系统全攻略:https://jingyan.baidu.com/article/c275f6bacc3 ...

  10. struts2 一些注解

    实现的JSP页面位置 web-root/jsp/user/add.jsp /update.jsp // /* @Namespace("/t") @AllowedMethods(va ...