6 patten
:array [0..maxn
] of string;
22 for i
:=1 to s
do readln(patten
[i
]);
25 function max(p
,q
:longint):longint;
27 if p
>q
then exit(p
) else exit(q
);
30 function match(st
:string):boolean;
36 for i
:=1 to s
do if pos(patten
[i
],st
)=1 then exit(true);
42 sum
,opt
:array [0..maxn
,0..maxn
] of longint;
45 fillchar(sum
,sizeof(sum
),0);
46 fillchar(opt
,sizeof(opt
),0);
48 for i
:=len
downto 1 do
50 if match(copy(text,i
,j
-i
+1)) then sum
[i
,j
]:=sum
[i
+1,j
]+1 else sum
[i
,j
]:=sum
[i
+1,j
];
55 opt
[i
,j
]:=max(opt
[i
,j
],opt
[i
-1,k
]+sum
[k
+1,j
]);