poj 2570 Fiber Network floyd算法
来源:互联网 发布:小脑袋调价软件 编辑:程序博客网 时间:2024/04/29 10:51
题意:
在一个有n个结点的图中,点a,b之间可以有属于不同公司的边,现在要查询对于点a,b,有哪些公司可以从属于本公司的边上从a到b。
思路:
对每个公司都建图,直接floyd。
代码:
//poj 2570 //sepNINE#include <iostream>using namespace std;const int maxN=210;int g[30][maxN][maxN];int main(){int n;while(scanf("%d",&n)==1&&n){int a,b,i,j,k,t,x;char tmp[32];memset(g,-1,sizeof(g));while(1){scanf("%d%d",&a,&b);if(a==0)break;scanf("%s",tmp);for(i=0;tmp[i]!='\0';++i){x=tmp[i]-'a';g[x][a][b]=1;}}for(t=0;t<26;++t)for(k=1;k<=n;++k)for(i=1;i<=n;++i)for(j=1;j<=n;++j)if(g[t][i][k]!=-1&&g[t][k][j]!=-1)g[t][i][j]=1;while(1){scanf("%d%d",&a,&b);if(a==0)break;int flag=0;for(t=0;t<26;++t)if(g[t][a][b]==1){printf("%c",t+'a');flag=1;}if(flag==0)printf("-");printf("\n");}printf("\n");}return 0;}
0 0
- poj 2570 Fiber Network floyd算法
- poj 2570 Fiber Network Floyd
- poj 2570 Fiber Network(floyd)
- poj 2570 Fiber Network(最短路+Floyd)
- POJ--2570--Fiber Network【floyd+位运算】
- poj 2570 Fiber Network (Floyd)
- Poj 2570 Fiber Network【Floyd+状态压缩】
- POJ 2570 Fiber Network(floyd闭包)
- [floyd]poj 2570 fiber network #floyd+位运算
- poj 2570 Fiber Network(floyd)
- poj 2570 Fiber Network(传递闭包,floyd+位运算)
- POJ 2570 Fiber Network(Floyd传递闭包+状态压缩)
- POJ 2570Fiber Network(Floyd+位运算)
- poj 2570 Fiber Network --floyd求传递闭包加位运算
- poj 2570 Fiber Network Floyd思想+二进制处理
- POJ 2570 Fiber Network
- POJ 2570 Fiber Network
- POJ-2570-Fiber Network
- Evaluate Reverse Polish Notation --leetcode
- jsp监听器实现在线人数统计
- tcpDump包的解封读取(附源代码)
- C#3.0新特性之扩展方法介绍
- 关于vs2013中的BrowserLink问题
- poj 2570 Fiber Network floyd算法
- 皇帝不是吃喝玩乐
- Javascript 基础知识 - 操作符 - typeof & instanceof
- Nat,桥接,DHCP,路由器,VMWARE的一些理解
- opengl实现直线扫描算法和区域填充算法
- 光速开发
- windows下文本在ubuntu下乱码解决之道
- Linux挂载Windows NFS server
- ARP与RARP协议详解 (三)