Pagini recente » Cod sursa (job #678561) | Cod sursa (job #2228975) | Cod sursa (job #1412192) | Cod sursa (job #1013892) | Cod sursa (job #120503)
Cod sursa(job #120503)
program alex;
var f:text;
as,ev:boolean;
n,m,k,i,j,q,w,d:longint;
a:array[1..1000,0..3]of integer;
b,c:array[1..1000]of integer;
begin
assign(f,'dusman.in');reset(f);
readln(f,n,k,m);
for i:=1 to m do
begin
read(f,q,w);
a[q,0]:=a[q,0]+1;
a[q,a[q,0]]:=w;
a[w,0]:=a[w,0]+1;
a[w,a[w,0]]:=q;
end;
close(f);
i:=1;
b[1]:=0;
d:=0;
while d<k do
begin
repeat
if b[i]<n then begin
b[i]:=b[i]+1;
as:=true;
end
else as:=false;
if as then begin
ev:=true;
for j:=1 to i-1 do
if b[i]=b[j]then ev:=false;
if i>=2 then if(b[i]=a[b[i-1],1])or(b[i]=a[b[i-1],2])or(b[i]=a[b[i-1],3])then ev:=false;
end;
until(not as)or(as and ev);
if as then if i=n then d:=d+1
else begin
i:=i+1;
b[i]:=0;
end
else i:=i-1;
end;
assign(f,'dusman.out');rewrite(f);
for i:=1 to n do
write(f,b[i],' ');
close(f);
end.