题意就是 给你 n个点 m条边 每条边有些公司支持 问 a点到b点的路径有哪些公司可以支持 这里是一条路径中要每段路上都要有该公司支持 才算合格的一个公司
// floyd 加 位运算
// 将每个字符当成二进制中的一位就好
#include <iostream>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
#define MOD 1000000007
#define maxn 210
int dp[maxn][maxn];
int main(){ int n;
int A,B;
char ch[];
int i,j,k;
while(scanf("%d",&n),n){
memset(dp,,sizeof(dp));
while(scanf("%d %d",&A,&B),A|B){
scanf("%s",ch);
for(i=;ch[i]!='\0';i++)
dp[A][B]|=(<<(ch[i]-'a')); }
for(k=;k<=n;k++)
for(i=;i<=n;i++)
for(j=;j<=n;j++)
dp[i][j]|=(dp[i][k]&dp[k][j]);
while(scanf("%d %d",&A,&B),A|B){
if(!dp[A][B]) printf("-");
for(i=dp[A][B],j=;i>;i=i>>,j++)
if(i&)
printf("%c",j+'a');
printf("\n");
}
printf("\n");
} }

zoj 1967 Fiber Network/poj 2570的更多相关文章

  1. POJ 2570 Fiber Network(最短路 二进制处理)

    题目翻译 一些公司决定搭建一个更快的网络.称为"光纤网". 他们已经在全世界建立了很多网站.这 些网站的作用类似于路由器.不幸的是,这些公司在关于网站之间的接线问题上存在争论,这样 ...

  2. POJ 1459 Power Network / HIT 1228 Power Network / UVAlive 2760 Power Network / ZOJ 1734 Power Network / FZU 1161 (网络流,最大流)

    POJ 1459 Power Network / HIT 1228 Power Network / UVAlive 2760 Power Network / ZOJ 1734 Power Networ ...

  3. POJ 2579 Fiber Network(状态压缩+Floyd)

    Fiber Network Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3328   Accepted: 1532 Des ...

  4. ZOJ - 1586 QS Network (Prim)

    ZOJ - 1586 QS Network (Prim) #include<iostream> #include<cstring> using namespace std; + ...

  5. A - Wireless Network POJ - 2236-kuangbin带你飞

    A - Wireless Network POJ - 2236 Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 50348 ...

  6. 树的最小支配集 E - Cell Phone Network POJ - 3659 E. Tree with Small Distances

    E - Cell Phone Network POJ - 3659 题目大意: 给你一棵树,放置灯塔,每一个节点可以覆盖的范围是这个节点的所有子节点和他的父亲节点,问要使得所有的节点被覆盖的最少灯塔数 ...

  7. 树形dp compare E - Cell Phone Network POJ - 3659 B - Strategic game POJ - 1463

    B - Strategic game POJ - 1463   题目大意:给你一棵树,让你放最少的东西来覆盖所有的边   这个题目之前写过,就是一个简单的树形dp的板题,因为这个每一个节点都需要挺好处 ...

  8. ZOJ 1967 POJ 2570 Fiber Network

    枚举起点和公司,每次用DFS跑一遍图,预处理出所有的答案.询问的时候很快就能得到答案. #include<cstdio> #include<cmath> #include< ...

  9. Fiber Network ZOJ 1967(Floyd+二进制状态压缩)

    Description Several startup companies have decided to build a better Internet, called the "Fibe ...

随机推荐

  1. lucas求组合数C(n,k)%p

    Saving Beans http://acm.hdu.edu.cn/showproblem.php?pid=3037 #include<cstdio> typedef __int64 L ...

  2. [转载]ASP.NET对路径"xxxxx"的访问被拒绝的解决方法小结

    异常详细信息: System.UnauthorizedAccessException: 对路径“D:/temp1/MyTest.txt”的访问被拒绝     在windows 2003下,在运行web ...

  3. error X3025:global variables are implicitly constant, enable compatibility mode to allow modification

    global variables are implicitly constant, enable compatibility mode to allow modification http://xbo ...

  4. 在线最优化求解(Online Optimization)之三:FOBOS

    在线最优化求解(Online Optimization)之三:FOBOS FOBOS (Forward-Backward Splitting)是由John Duchi和Yoram Singer提出的[ ...

  5. Web Server 和 HTTP协议(转)

    转自:http://www.kuqin.com/shuoit/20150809/347488.html 一直在找实习,有点什么东西直接就在evernote里面记了,也没时间来更新到这里.找实习真是个蛋 ...

  6. Caching Tutorial

    for Web Authors and Webmasters This is an informational document. Although technical in nature, it a ...

  7. SDUT2484算术表达式的转换

    http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2484&cid=1182 题目描述 小明在学习了数据结构之后,突然想起了以前没有解决的算术 ...

  8. JavaSE GUI显示列表 JTable的刷新 重新加载新的数据

    JTable在显示所有数据之后,假如需要搜索某个名字,则会获取新的列表数据. 假设datas是JTable的数据,定义为: private Vector<Vector> datas = n ...

  9. div+css 定位浅析

    在用CSS+DIV进行布局的时候,一直对position的四个属性值relative,absolute,static,fixed分的不是很清楚,以致经常会出现让人很郁闷的结果. 先看下各个属性值的定义 ...

  10. TopCoder 603 div1 & div2

    div2 250pts MiddleCode 题意:s串长度为奇数时,将中间字符取掉并添加到t末尾:长度为偶数时,将中间两个较小的字符取掉并添加到末尾. 分析:直接做,学习了一下substr(s, p ...