Pagini recente » Cod sursa (job #2200206) | Cod sursa (job #1363420) | Cod sursa (job #2534453) | Cod sursa (job #1136286) | Cod sursa (job #115283)
Cod sursa(job #115283)
var n,m,k,i,j,x,y:integer;
a:array[1..1010,1..1010]of integer;
b,c:array[0..1010]of integer;
procedure back(x:integer);
var i,j:integer;
begin
if x>n then
begin
dec(k);
if k=0 then
begin
for i:=1 to n do write(b[i],' ');
end;
exit;
end;
for i:=1 to n do
begin
if (c[i]=1)or(a[i][b[x-1]]=1) then continue;
c[i]:=1;
b[x]:=i;
back(x+1);
c[i]:=0;
b[x]:=0;
if k=0 then exit;
end;
end;
begin
assign(input,'dusman.in');
reset(input);
assign(output,'dusman.out');
rewrite(output);
readln(n,k,m);
for i:=1 to m do
begin
readln(x,y);
a[x][y]:=1;
a[y][x]:=1;
end;
back(1);
close(output);
end.