Задача A-Свято цукерок
var
s1,s2,s3:string;
i,l:word;
c:char;
begin
read(c); while c<>#32 do begin s1:=s1+c; read(c); end;
read(c); while c<>#32 do begin s2:=s2+c; read(c); end;
read(c); while c in['0'..'9'] do begin s3:=s3+c; read(c); end;
l:=length(s1);
if length(s2)>l then l:=length(s2);
if length(s3)>l then l:=length(s3);
while length(s1)<l do s1:='0'+s1;
while length(s2)<l do s2:='0'+s2;
while length(s3)<l do s3:='0'+s3;
if s1>s2 then
if s1>s3 then writeln(s1) else writeln(s3)
else if s2>s3 then writeln(s2) else writeln(s3);
end.
Задача B-Змійка
var
f,f1 : text;
a:array[0..101,0..101] of 0..1;
n,m,i,j,k,s,dl: integer;
l:boolean;
begin
assign(f,'z2.dat'); assign(f1,'z2.sol');
reset(f); rewrite(f1);
readln(f,n,m);
for i:=1 to n do
for j:=1 to m do
read(f, a[i,j]);
i:=1; k:=0; dl:=0;
for i:=1 to n do
for j:=1 to m do
if a[i,j]=1 then
begin dl:=dl+1; s:=a[i,j-1]+a[i,j+1]+a[i-1,j]+a[i+1,j];
if s=1 then k:=k+1
end;
if (s=0) or (k=2) then begin writeln(f1,'No'); writeln(f1,dl) end else begin writeln(f1,'Yes'); writeln(f1,dl) end;
Close(f1);close(f)
end.
Задача C-Командна гра
var
f,f1:text;
a:array[1..100] of set of 1..50;
b: array[1..100] of boolean;
i,j,k,n,m:integer;
c,d:set of 1..50;
r:boolean;
begin
assign(f,'z3.dat');
reset(f);
readln(f,n);
for i:=1 to n do
begin
read(f,m); if m=0 then a[i]:=[]
else for j:=1 to m do begin read(f,k); a[i]:=a[i]+[k]; end;
end;
c:=a[1]; k:=1; b[1]:=true;
repeat
r:=false; d:=c;
for i:= 2 to n do
if (a[i]*c <> []) and not b[i] then begin c:=c+a[i]; k:=k+1; b[i]:=true end;
if d<>c then r:=true;
until not r;
assign(f1,'z3.sol'); rewrite(f1);
writeln(f1,k); close(f1)
end.