Cod sursa(job #537101)
| Utilizator | Data | 20 februarie 2011 00:31:49 | |
|---|---|---|---|
| Problema | Cel mai lung subsir comun | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 1.26 kb |
program cel_mai_lung_subsir_comun;
var a:array [1..1024] of integer;
b:array [1..1024] of integer;
c:array [1..1024] of integer;
x,y,z,i,j,k:0..256;
f,g:text;
cond:boolean;
begin
assign (f,'cmlsc.in'); reset (f);
assign (g,'cmlsc.out'); rewrite (g);
read (f,x);
read (f,y);
readln (f);
for i:=1 to x do read (f,a[i]);
readln (f);
for j:=1 to y do read (f,b[j]);
z:=0;
for i:=1 to x do for j:=1 to y do if (a[i]=b[j]) then begin cond:=true;
for k:=1 to z do if (a[i]=c[k]) then begin cond:=false;
break;
end;
if (cond) then begin z:=z+1;
c[z]:=a[i];
break;
end;
end;
writeln (g,z);
for i:=1 to z do write (g,c[i],' ');
close (f);
close (g);
end.
