mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 2531_martin31hao.cpp
From http://blog.csdn.net/martin31hao/article/details/8098302
This commit is contained in:
parent
f10d9ad19c
commit
f920a37956
45
POJ/2531_martin31hao.cpp
Normal file
45
POJ/2531_martin31hao.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include<cstdio>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
const int maxn = 30;
|
||||
int n, ans;
|
||||
int a[maxn][maxn];
|
||||
int dep[maxn];
|
||||
|
||||
void dfs(int id, int data)
|
||||
{
|
||||
dep[id] = 1;
|
||||
int tmp = data;
|
||||
for(int i = 1; i <= n; i ++)
|
||||
{
|
||||
if(dep[i] == 0)
|
||||
tmp += a[i][id];
|
||||
else
|
||||
tmp -= a[i][id];
|
||||
}
|
||||
if(ans < tmp)
|
||||
ans = tmp;
|
||||
for(int i = id + 1; i <= n; i ++)
|
||||
{
|
||||
if(tmp > data)
|
||||
{
|
||||
dfs(i, tmp);
|
||||
dep[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
while(~scanf("%d", &n))
|
||||
{
|
||||
for(int i = 1; i <= n; i ++)
|
||||
for(int j = 1; j <= n; j ++)
|
||||
scanf("%d", &a[i][j]);
|
||||
memset(dep, 0, sizeof(dep));
|
||||
ans = 0;
|
||||
dfs(1, 0);
|
||||
printf("%d\n", ans);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user