#include #include #include #include #define size 10001 #define _clr(x) memset(x,0xff,sizeof(int)*26) #define inf 1000000000 using namespace std; int g[26][26]; bool l[26][size]; int KM(int n); bool HaveLetter[26]; struct loc { int a[size]; int len; loc(){len = 0;} void add(int val) { a[len++] = val; } }locate1[26],locate2[26],rem2,rem1; void InitGraph(int n) { int i,j,A; memset(HaveLetter,0,sizeof(HaveLetter)); for(i=0;i<26;i++) locate2[i].len = 0; for (i=0;il1[i]?g[i][j]:l1[i]; for (i=0;i=0;j=p) match2[j]=k=t[j],p=match1[k],match1[k]=j; } if (match1[i]<0) { for (i--,p=inf,k=0;k<=q;k++) for (j=0;j