标签:des style http color os io 使用 ar strong
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 3107 | Accepted: 1427 |
Description
Input
Output

Sample Input
3 1 2 abc 2 3 ad 1 3 b 3 1 de 0 0 1 3 2 1 3 2 0 0 2 1 2 z 0 0 1 2 2 1 0 0 0
Sample Output
ab d - z -
公司使用小写字母表示的,最多26个公司,故可以用二进制的位来表示公司。
#include"stdio.h"
#include"string.h"
#include"vector"
#include"queue"
#include"iostream"
#include"algorithm"
using namespace std;
#define N 205
const int inf=(int)1e10;
int g[N][N];
int main()
{
int i,j,k,n,a,b;
char str[27];
while(scanf("%d",&n),n)
{
memset(g,0,sizeof(g));
while(scanf("%d%d",&a,&b),a||b)
{
scanf("%s",str);
for(i=0;str[i]!='\0';i++) //某一位上为一代表该公司可以连接a,b
g[a][b]|=1<<(str[i]-'a');
}
for(k=1;k<=n;k++)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
g[i][j]|=(g[i][k]&g[k][j]);
}
}
}
while(scanf("%d%d",&a,&b),a||b)
{
if(!g[a][b])
{
printf("-\n");
continue;
}
for(char i='a';i<='z';i++)
{
if(g[a][b]&(1<<i-'a'))
printf("%c",i);
}
puts("");
}
puts("");
}
return 0;
}
poj 2570 Fiber Network (Floyd)
标签:des style http color os io 使用 ar strong
原文地址:http://blog.csdn.net/u011721440/article/details/39101927