poj1129 2010.2.18
来源:互联网 发布:python 发送syslog 编辑:程序博客网 时间:2024/06/03 16:16
poj1129 2010.2.18
#include <iostream>bool map[27][27];int ans[27],n;bool check(int p){int i;for(i=0;i<n;i++){if((map[p][i]||map[i][p])&&ans[p]==ans[i])return false;}return true;}bool dfs(int p,int depth){if(p==n)return true;ans[p]++;while(!check(p))ans[p]++;if(ans[p]>depth)return false;elsereturn dfs(p+1,depth);}int main(){int i,x,y,j;char s[100];//freopen("in.txt","r",stdin);while(scanf("%d\n",&n),n){memset(map,false,sizeof(map));for(i=0;i<n;i++){gets(s);x=s[0]-'A';for(j=2;s[j]!='\0';j++){y=s[j]-'A';map[x][y]=true;}}for(i=1;i<=3;i++){memset(ans,0,sizeof(ans));if(dfs(0,i))break;}if(i==1)printf("%d channel needed.\n",i);elseprintf("%d channels needed.\n",i);}return 0;}
0 0
- poj1129 2010.2.18
- poj1129
- POJ1129
- POJ1129
- poj1129
- poj1129
- POJ1129
- POJ1129
- Poj1129
- poj1129
- poj1129
- poj1129
- poj1129 dfs
- [DFS]poj1129
- poj1129 poj1106
- POJ1129—Channel Allocation
- POJ1129--Channel Allocation
- POJ1129 Channel Allocation
- dsds
- usaco milk3
- poj2262 2010.2.17
- this方法获取a标签ID值及内容;idx传参
- UVa 1594 Ducci Sequence
- poj1129 2010.2.18
- usaco milk
- 第一届蓝桥杯C/C++组编程题1 黑色星期五
- android 用java动态设置布局(增添删除修改布局)
- 哈理工OJ 1708 许可证【临街表+dfs】
- 装IIS时遇到一个Server Application Error错误解决
- usaco namenum
- 经典算法学习——希尔排序
- iOS 浮点型四舍五入精确值问题