poj 2531
来源:互联网 发布:linux ansi utf8 编辑:程序博客网 时间:2024/04/29 08:27
暴力搜索 因为数据太弱 并不想去加什么剪枝
#include <iostream>#include <cstring>#include <vector>#include <algorithm>using namespace std;#define met(a, b) memset(a, b, sizeof(a))const int N = 25;int g[N][N], vis[N], n, ans;void dfs (int k, int sum);int main (){ while (cin >> n) { for (int i=0; i<n; i++) for (int j=0; j<n; j++) cin >> g[i][j]; ans = 0; met (vis, 0); vis[0] = 1; dfs (0, 0); cout << ans << endl; } return 0;}void dfs (int k, int sum){ int x = sum; for (int i=0; i<n; i++) { if (vis[i]) x -= g[k][i]; else x += g[k][i]; } if (x > ans) ans = x; for (int i=k+1; i<n; i++) { if (!vis[i]) { vis[i] = 1; dfs (i, x); vis[i] = 0; } }}
0 0
- poj 2531
- POJ 2531
- POJ 2531
- poj 2531
- POJ 2531
- POJ 2531
- poj-2531
- poj 2531
- poj 2531
- poj - 2531
- poj 2531
- POJ-2531
- POJ 2531(随机化思想)
- poj 2531 Network Saboteur
- Poj 2531 Network Saboteur
- POJ 2531 Network Saboteur
- POJ 2531 Network Saboteur
- POJ 2531 (DFS+剪枝)
- android studio 的build tools的下载 网址
- 黑马程序员
- 9.1 Ransac 匹配质量判断
- 笔记---c++ primer——struct(一)
- Sine之舞
- poj 2531
- ubuntu中安装搜狗拼音输入法
- 黑马程序员
- The file “Pods.xcconfig” couldn’t be opened because there is no such file.
- 用js实现类数组转换为数组
- [菜鸟试水]关于Nodejs搭建后台API服务(Mysql-Restify)
- android ViewPager+FragmentStatePagerAdapter无限循环FragmentStatePagerAdapter
- 【BOI2007】【BZOJ1176】Mokia
- Linux中如何创建静态库和动态库