Pagini recente » Cod sursa (job #1738115) | Cod sursa (job #1475943) | Cod sursa (job #179937) | Cod sursa (job #1094590) | Cod sursa (job #423968)
Cod sursa(job #423968)
#include <fstream>
using namespace std;
short int v[1<<4][1<<4],q[1<<4];
int n,k=1<<4,maxx=0;
long long cou;
ifstream in("copii.in");
ofstream out("copii.out");
void check()
{
bool y[1<<4][1<<4];
int i,j,nr=0;
for (i=1;i<=maxx;i++)
for (j=1;j<=maxx;j++)
y[i][j]=false;
for (i=1;i<=maxx;i++)
for (j=1;j<=maxx;j++)
if (v[i][j] && q[i]!=q[j])
y[q[i]][q[j]]=true;
for (i=1;i<=maxx;i++)
for (j=1;j<=maxx;j++)
nr+=y[i][j];
/*for (i=1;i<=n;i++)
out<<q[i]<<" ";
out<<"\n\n";
for (i=1;i<=maxx;i++)
for (j=1;j<=maxx;j++)
out<<y[i][j]<<" ";
out<<"\n";*/
if (nr==maxx*(maxx-1))
cou++;
}
void scrie()
{
for(int i=1 ; i<=n ; ++i)
out<<q[i]<<" ";
out<<"\n";
}
void teams(int p)
{
if (p==n+1)
{
check();
return;
}
for (int i=1;i<=maxx;i++)
{
q[p]=i;
teams(p+1);
}
q[p]=++maxx;
teams(p+1);
--maxx;
}
int main()
{
int i,j;
char s[10];
in>>n;
in.get();
for (i=1;i<=n;i++)
{
in.getline(s,n+1);
for (j=1;j<=n;j++)
{
v[i][j]=s[j-1]-'0';
v[i][0]+=v[i][j];
}
}
/*
for (n=2;n<q;n++)
teams(1);
*/
teams(1);
out<<cou;
return 0;
}