#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int N=20;
int g[N][N],n;
bool st[N];
LL ans;
void dfs(int u,LL x) //x记录答案
{
if(u==n)
{
ans=max(ans,x);
return;
}
int l=0; //先固定第一元素
for(int i=1;i<=2*n-1;i++)
if(!st[i])
{
l=i;
break;
}
st[l]=true;
for(int i=l+1;i<=2*n;i++)
if(!st[i]) //再固定第二元素
{
st[i]=true;
dfs(u+1,x^g[l][i]); //继续搜u+1
st[i]=false;
}
st[l]=false;
}
int main()
{
cin>>n;
for(int i=1;i<=2*n-1;i++)
for(int j=i+1;j<=2*n;j++)
cin>>g[i][j];
dfs(0,0);
cout<<ans<<endl;
return 0;
}
二维dfs
最新推荐文章于 2023-09-07 17:39:14 发布