Pagini recente » salsa | Cod sursa (job #1601833) | Cod sursa (job #182641) | Cod sursa (job #148084) | Cod sursa (job #252184)
Cod sursa(job #252184)
PROGRAM lista;
var f:text;
begin
assign(f,'nrcuv.in');
reset(f);
readln(f,n,m);
for i:=1 to m do
begin
readln(f,a,b);
mat[a,b]:=1;
mat[b,a]:=1;
end;
j:=1;
st[j]:=pred('a');
while j>0 do
begin
repeat
if st[j]<'z' then begin
st[j]:=succ[st[j]);
as:=true
end
else as:=false;
if as then if mat[st[j],st[j-1]]=1 then ev:=false
else ev:=true
until (not as) or (as and ev);
if as then if j=n then nr:=(nr+1)mod 104659
else begin
j:=j+1;
st[j]:=pred('a')
end
else j:=j-1
end;
end.