NKH - Tách Từ
Tác giả: flashmt
Ngôn ngữ: Pascal
var a,b,c:string;
la,lb,lc:byte;
d,e:array[0..200] of byte;
procedure rf;
begin
readln(a); la:=length(a);
readln(b); lb:=length(b);
readln(c); lc:=la+lb;
end;
procedure att(i:byte);
var j,k,q:byte;
begin
if i>la then exit;
for j:=e[i-1]+1 to lc do
if c[j]=a[i] then
begin
d[j]:=1;
e[i]:=j;
if i=la then
begin
q:=1;
for k:=1 to lc do
if (d[k]=0) then
begin
if c[k]=b[q] then inc(q)
else break;
end;
if q=lb+1 then
begin
for k:=1 to lc do write(2-d[k]);
halt;
end;
end;
att(i+1);
d[j]:=0;
e[i]:=0;
end;
end;
procedure pr;
begin
fillchar(d,sizeof(d),0);
fillchar(e,sizeof(e),0);
att(1);
end;
begin
rf;
pr;
end.