Pagini recente » Cod sursa (job #2008806) | Cod sursa (job #2018825) | Profil M@2Te4i | Cod sursa (job #392790)
Cod sursa(job #392790)
#include<stdio.h>
#include<bitset>
using namespace std;
int i,j,n,k,m,rez[1001],ok;
bitset <1001> a[1001];
bitset <1001> fol;
void back(int i)
{
if(i>n)
{
--k;
if(!k)
{
for(int j=1;j<=n;++j) printf("%d ",rez[j]);
printf("\n");
ok=1;
}
return;
}
for(int j=1;j<=n&&!ok;++j)
if(!fol[j]&&!a[rez[i-1]][j])
{
rez[i]=j;
fol[j]=1;
back(i+1);
fol[j]=0;
}
}
int main()
{
freopen("dusman.in","r",stdin);
freopen("dusman.out","w",stdout);
scanf("%d %d %d",&n,&k,&m);
for(i=1;i<=m;++i)
{
int l=0,c=0;
scanf("%d %d",&c,&l);
a[c][l]=1;
a[l][c]=1;
}
back(1);
fclose(stdin);
fclose(stdout);
return 0;
}