The feeling is very interesting, it is not difficult to think.
F[I][J] |= f[i][k] & F[k][j]
#include <cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<climits>#include<string>#include<iostream>#include<map>#include<cstdlib>#include<list>#include<stack>using namespaceStd;typedefLong LongLL;Const intMAXN =205;intN,VAL[MAXN][MAXN];BOOLE[MAXN][MAXN];Charbuf[1024x768];intGetval (Char*s) {intLen = strlen (s), ret =0; for(inti =0; I < len;i++) {ret|= (1<< (S[i]-'a')); } returnret;}voidFloyd () { for(inti =1; I <= n;i++) { for(intj =1; J <= n;j++) { for(intK =1; k <= n;k++) {Val[j][k]|= Val[j][i] &Val[i][k]; } } }}intMain () { while(SCANF ("%d",&N) {memset (Val,0,sizeof(Val)); intb; while(SCANF ("%d%d",&a,&b), a) {scanf ("%s", BUF); VAL[A][B]=Getval (BUF); } Floyd (); while(SCANF ("%d%d",&a,&b), a) {intCNT =0; for(inti =0; I < -; i++) { if(Val[a][b] & (1<<i)) {CNT++; Putchar (i+'a'); } } if(CNT = =0) Putchar ('-'); Puts (""); } puts (""); } return 0;}