Pagini recente » Cod sursa (job #2386290) | Cod sursa (job #907099) | Cod sursa (job #1670404) | Cod sursa (job #2566228) | Cod sursa (job #728235)
Cod sursa(job #728235)
#include<stdio.h>
char a[11][11];
bool echipai[11][11];
int n,v[11],nrechipe=0;
void prelucrare (int x)
{
int i,j;
for(i=1 ; i<=x ; i++)
for(j=1 ; j<=x ; j++)
echipai[i][j]=false;
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
if (a[i][j]=='1')
echipai[v[i]][v[j]]=true;
for (i=1;i<=x;i++)
for (j=1;j<=x;j++)
{
if (echipai[i][j]==false && i!=j)
return;
}
nrechipe++;
return;
}
void bkt (int p,int max)
{
int i;
if (p-1==n)
{
prelucrare(max-1);
return;
}
for (i=1;i<=max;i++)
{
v[p]=i;
if (i==max)
bkt(p+1,max+1);
else
bkt(p+1,max);
}
}
int main ()
{
int i;
freopen("copii.in","r",stdin);
freopen("copii.out","w",stdout);
scanf("%d\n",&n);
for (i=1;i<=n;i++)
gets(1+a[i]);
bkt(1,1);
printf("%d",nrechipe-1);
return 0;
}