#include <cstdio>
int n;
int m[15][15]={};
int check[15]={};
int max=0;
void f(int r, int s)
{
if (r==n)
{
if (s>max)
{
max=s;
}
return;
}
for (int i=0; i<n; i++)
{
if (check[i]==0)
{
check[i]=1;
f(r+1, s+m[r][i]);
check[i]=0;
}
}
}
int main()
{
scanf("%d",&n);
for (int i=0; i<n; i++)
{
for (int j=0; j<n; j++)
{
scanf("%d",&m[i][j]);
}
}
f(0,0);
printf("%d\n",max);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: