hdoj1373 Channel Allocation(极大团)
题意是有若干个接收器,给出每个接收器的相邻接收器。相邻的接收器不能使用同一信号频道。问所需要的信号频道数。
求该无向图的极大团。
#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(极大团)的更多相关文章
- poj1129 Channel Allocation
Channel Allocation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14361 Accepted: 73 ...
- 迭代加深搜索 POJ 1129 Channel Allocation
POJ 1129 Channel Allocation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14191 Acc ...
- Channel Allocation
Channel Allocation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13231 Accepted: 6774 D ...
- poj1129 Channel Allocation(染色问题)
题目链接:poj1129 Channel Allocation 题意:要求相邻中继器必须使用不同的频道,求需要使用的频道的最少数目. 题解:就是求图的色数,这里采用求图的色数的近似有效算法——顺序着色 ...
- Channel Allocation (poj 1129 dfs)
Language: Default Channel Allocation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12 ...
- Channel Allocation(DFS)
Channel Allocation Time Limit : 2000/1000ms (Java/Other) Memory Limit : 20000/10000K (Java/Other) ...
- POJ 2989 All Friends 极大团计数
POJ 2989 题意:给定一个无向图(节点数小于128)求极大团(不包含在更大的团中)的总数. 对最大团,极大团不熟悉的,建议先阅读最大团搜索问题 ZOJ 1492 再来看本题. 本题数据有限,可以 ...
- All Friends 极大团
搞懂了什么是团 什么是极大团 什么是最大团 极大团就是 不是任何团的真子集 最大团就是点数最多的极大团 这题就是求极大团的个数 用bk算法 #include <iostream> ...
- POJ 1129 Channel Allocation(DFS)
Channel Allocation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13173 Accepted: 67 ...
随机推荐
- Easyui form 处理 Laravel 返回的 Json 数据
默认地,Easyui Form 请求的格式是 Html/Text,如果服务端 Laravel 返回的数据是 Json 格式,则应当在客户端进行解析.以下是 Easyui 官方文档的说明: Handle ...
- 理解OAuth 2.0 (摘自阮一峰网络日志)
OAuth是一个关于授权(authorization)的开放网络标准,在全世界得到广泛应用,目前的版本是2.0版. 本文对OAuth 2.0的设计思路和运行流程,做一个简明通俗的解释,主要参考材料为R ...
- [SoapUI] 在Jenkins上传递project级别的参数给case
- Can't use Subversion command line client: svn. Errors found while svn working copies detection.
idea 报错: Can't use Subversion command line client: svn. Errors found while svn working copies detect ...
- 21 Survival of Desert Life 沙漠生命的延续
Survival of Desert Life 沙漠生命的延续 ① Some desert animals can survive the very strong summer heat and dr ...
- BZOJ 1003 物流运输 (dp + dijkstra)
1003: [ZJOI2006]物流运输 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 8672 Solved: 3678[Submit][Stat ...
- UVa 10382 Watering Grass (区间覆盖贪心问题+数学)
题意:有一块长为l,宽为w的草地,在其中心线有n个喷水装置,每个装置可喷出以p为中心以r为半径的圆, 选择尽量少的装置,把草地全部润湿. 析:我个去啊,做的真恶心,看起来很简单,实际上有n多个坑啊,首 ...
- 编译hbase-1.2.3源代码
目录 目录 1 1. 约定 1 2. 安装jdk 1 3. 安装maven 1 4. 网络配置 2 4.1. eclipse 3 4.2. maven 3 5. 从hbase官网下载源代码包: 4 6 ...
- 伪共享(False Sharing)
原文地址:http://ifeve.com/false-sharing/ 作者:Martin Thompson 译者:丁一 缓存系统中是以缓存行(cache line)为单位存储的.缓存行是2的整数 ...
- PAT甲 1012. The Best Rank (25) 2016-09-09 23:09 28人阅读 评论(0) 收藏
1012. The Best Rank (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...