# [AHOI2005]病毒检测

Description

Input

Output

Sample Input

A*G?C
3
AGTC
AGTGTC
AGTGC


Sample Output

1


/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
static char buf[1000000],*p1=buf,*p2=buf;
}
inline int frd(){
int x=0,f=1;char ch=gc();
for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')    f=-1;
for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<1)+(x<<3)+ch-'0';
return x*f;
}
int x=0,f=1;char ch=getchar();
for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<1)+(x<<3)+ch-'0';
return x*f;
}
inline void print(int x){
if (x<0)    putchar('-'),x=-x;
if (x>9)	print(x/10);
putchar(x%10+'0');
}
const int N=5e2;
bool f[(N<<1)+10][N+10];
char T[(N<<1)+10];
int c[(N<<1)+10];
int main(){
scanf("%s",T+1);
while (Q--){
static char s[N+10];
memset(f,0,sizeof(f));
memset(c,63,sizeof(c));
scanf("%s",s+1);
int len=strlen(s+1);
f[0][0]=1;
for (int i=1;i<=lenT;i++){
if (T[i]!='*'){
for (int j=1;j<=len;j++){
if (T[i]=='?'||T[i]==s[j]){
f[i][j]|=f[i-1][j-1];
if (T[i-1]=='*'&&c[i-1]<j)	f[i][j]=1;
}
}
}else{
if (i==1)	f[i][0]=1;
for (int j=1;j<=len;j++){
f[i][j]|=(f[i-1][j]|f[i][j-1]);
if (f[i][j])	c[i]=min(c[i],j);
}
}
}
if (f[lenT][len])	Ans--;
}
printf("%d\n",Ans);
return 0;
}

posted @ 2019-03-06 19:55  Wolfycz  阅读(170)  评论(0编辑  收藏  举报