POJ 1129.Channel Allocation
来源:互联网 发布:淘宝店已下架什么意思 编辑:程序博客网 时间:2024/05/17 10:39
题目:http://poj.org/problem?id=1129
AC代码(C++):
#include <iostream>#include <algorithm>#include <stdio.h>#include <vector>#include <queue>#include <math.h>#include <string>#include <string.h>#include <bitset>#define INF 0xfffffff#define MAXN 100105using namespace std;int n;bool map[30][30];int chan[30];void dfs(int x){if(x==n){return;}chan[x] = 1;for(int i = 0; i < n; i++){if(map[x][i]&&chan[i]==chan[x]){chan[x]++;i = -1;}}dfs(x+1);}int main(){while(cin>>n){if(n==0)break;memset(map,false,sizeof(map));memset(chan,0,sizeof(chan));char str[50];int u,v;for(int i = 0; i < n; i++){scanf("%s",&str);u = str[0] - 'A';for(int j = 2; j < strlen(str); j++){v = str[j] - 'A';map[u][v] = true;map[v][u] = true;}}for(int i = 0; i < n; i++)dfs(i);int max = 0;for(int i = 0; i < n; i++){if(chan[i]>max)max = chan[i];}if(max==1)cout<<"1 channel needed.\n";else cout<<max<<" channels needed.\n";}}总结: 水题.
阅读全文
0 0
- POJ 1129.Channel Allocation
- poj 1129 Channel Allocation
- poj 1129 Channel Allocation
- poj 1129 Channel Allocation
- poj 1129Channel Allocation
- poj 1129 Channel Allocation
- poj 1129 Channel Allocation
- POJ 1129 Channel Allocation
- POJ 1129 Channel Allocation
- POJ 1129 Channel Allocation
- POJ 1129 Channel Allocation
- POJ 1129 Channel Allocation
- poj 1129 Channel Allocation
- POJ 1129 Channel Allocation
- Channel Allocation(poj 1129 )
- poj 1129 Channel Allocation
- POJ 1129--Channel Allocation
- poj 1129 Channel Allocation
- Java中static和final用法
- HDOJ Wash JAVA超时 6000
- scikit-learn 中文文档-高斯过程-监督学习|ApacheCN
- UVA 11374 SPFA+路径打印
- 人工智能学习清单
- POJ 1129.Channel Allocation
- 两种快速排序的实现(C语言)
- Leetcode 113. Path Sum II
- Ubuntu14.04 增加Swap分区
- 一个轻量级的分布式RPC框架
- request、response 中文乱码问题与解决方式
- mysql 练习1 完成一个由 学生表 选课表 课程表 的一个多表查询
- 1003. Emergency (25)(java版)
- AngularJS http 服务