一开始给你m个n长度的原串 ,*可以代替1或者0 于是可以匹配出一个新串,现在要你找到一个新的模板串使模板最少。
好吧,就是一个基本上裸的二分图匹配可是由于自己还是太脑残,在debug的时候,改掉一个地方以后就会有连锁反应,导致其他的地方也会错,所以下一次debug的时候一定要关注一下上下面有没有牵连例如if 和 else 语句,注意,注意‘
其次,在找到原来串的时候我们用到状态压缩1的位置在哪里出现过来判重也是一个很不错的技巧
代码比较冗杂,又不想优化了
#include<cstdio>
#include<cstring>
#include<iostream>
#define maxn 2100
using namespace std;
int n,m,link[maxn],tot;
bool vis[maxn];
char s[1500];
bool used[maxn*maxn],can[maxn][maxn];
struct node{//-1代表品*
int ch[15];
void clear(){memset(ch,0,sizeof(ch)); }
bool operator ==(const node& b){
int _cnt=0;
for(int i=1;i<=n;i++){
if(b.ch[i]!=ch[i]){
_cnt++;
if(_cnt>1)return false;
}
}
return true;
}
}nod[maxn];
int dfs(int u){
for(int i=1;i<=tot;i++){
if(i!=u&&!vis[i]&&can[u][i]){