What's wrong with it?
program t1208;
const p=20;
var s,s1:array[1..p,1..3]of string[20];
a:string;
n,i,j,k,st,t,max,m,i1,j1:integer;
begin
readln(n);
for i:=1 to p do
for j:=1 to 3 do s[i,j]:='';
for i:=1 to n do
begin
readln(a);
t:=1; st:=1;
for j:=1 to length(a) do
if a[j]=' ' then
begin
for k:=st to j-1 do s[i,t]:=s[i,t]+a[k];
st:=j+1;
inc(t);
end
else if j=length(a) then for k:=st to j do s[i,t]:=s[i,t]+a
[k];
end;
if n=1 then begin writeln(1); halt; end;
m:=0;
for i:=1 to n do begin
if max>m then m:=max;
max:=0;
s1:=s;
for i1:=1 to n do for j1:=1 to 3 do
begin
if (s1[i1,j1]=s[i,1])and(i1<>i) then s1[i1,j1]:='';
if (s1[i1,j1]=s[i,2])and(i1<>i) then s1[i1,j1]:='';
if (s1[i1,j1]=s[i,3])and(i1<>i) then s1[i1,j1]:='';
end;
for j:=1 to n do
if (s1[j,1]<>'')and(s1[j,2]<>'')and(s1[j,3]<>'')
then begin
inc(max);
for i1:=1 to n do for j1:=1 to 3 do
begin
if s1[i1,j1]=s[j,1] then s1[i1,j1]:='';
if s1[i1,j1]=s[j,2] then s1[i1,j1]:='';
if s1[i1,j1]=s[j,3] then s1[i1,j1]:='';
end;
end;
end;
writeln(m);
end.
Re: What's wrong with it?
Try this:
6
a b c
b h j
c t y
aa bb cc
bb hh jj
cc tt yy
Output should be 4, but your pg output 3.