📄 ac1239.pas
字号:
program tju1239;
var
p,q:ansistring;
n,u,lp,lq,l,i,pp,pq,count:word;
function match(sp,sq,l:word):boolean;
var
i:word;
begin
for i:=1 to l do
if (p[sp+i]<>'?') and (q[sq+i]<>'?') and (p[sp+i]<>q[sq+i]) then begin
match:=false;exit;
end;
match:=true;
end;
begin
repeat
readln(p);lp:=length(p);
readln(n);count:=0;
if pos('*',p)=0 then
for u:=1 to n do begin
readln(q);lq:=length(q);
if (lp=lq) and match(0,0,lp) then inc(count);
end
else
for u:=1 to n do begin
readln(q);lq:=length(q);
pp:=pos('*',p);
if (lq<pp-1) or not match(0,0,pp-1) then continue;
pq:=pp-1;
for i:=pp+1 to lp do
if p[i]='*' then begin
l:=i-pp-1;
while pq+l<=lq do
if match(pp,pq,l) then break else inc(pq);
if pq+l>lq then break;
pp:=i;inc(pq,l);
end;
l:=lp-pp;
if (pq+l<=lq) and match(pp,lq-l,l) then inc(count);
end;
writeln(n-count);
until seekeof;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -