Network Saboteur(dfs)
http://poj.org/problem?id=2531
不太理解这个代码。。。
#include <stdio.h>
#include <string.h>
int map[][],v[];
int n,max;
void dfs(int row,int sum)
{ int ans = sum;
v[row] = ;
for (int i = ; i <= n; i ++)
{
if (v[i]==)
ans += map[row][i];
else
ans -= map[row][i];
}
if (ans > max)
max = ans;
for (int i = row+; i <= n; i ++)
{
if (ans > sum)
{
dfs(i,ans);
v[i] = ;
}
}
}
int main()
{
scanf("%d",&n);
max = ;
memset(v,,sizeof(v));
for (int i = ; i <= n; i ++)
{
for (int j = ; j <= n; j ++)
{
scanf("%d",&map[i][j]);
}
}
dfs(,);
printf("%d\n",max);
return ; }
Network Saboteur(dfs)的更多相关文章
- POJ-2561 Network Saboteur(DFS)
题目: A university network is composed of N computers. System administrators gathered information on t ...
- PKU 2531 Network Saboteur(dfs+剪枝||随机化算法)
题目大意:原题链接 给定n个节点,任意两个节点之间有权值,把这n个节点分成A,B两个集合,使得A集合中的每一节点与B集合中的每一节点两两结合(即有|A|*|B|种结合方式)权值之和最大. 标记:A集合 ...
- poj2531 Network Saboteur
Network Saboteur Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11122 Accepted: 5372 ...
- POJ2531Network Saboteur(DFS+剪枝)
Network Saboteur Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10391 Accepted: 4990 ...
- Network Saboteur 分类: 搜索 POJ 2015-08-09 19:48 7人阅读 评论(0) 收藏
Network Saboteur Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10147 Accepted: 4849 Des ...
- Network Saboteur(搜索)
Network Saboteur POJ2531 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10351 Accept ...
- POJ2531——Network Saboteur(随机化算法水一发)
Network Saboteur DescriptionA university network is composed of N computers. System administrators g ...
- CSU-ACM2016暑假集训训练2-DFS(C - Network Saboteur)
C - Network Saboteur Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu ...
- Network Saboteur (DFS)
题目: A university network is composed of N computers. System administrators gathered information on t ...
随机推荐
- linux下用scp命令在两个服务器之间传输文件,利用php_scp函数进行文件传输
在linux下利用scp进行文件传输, 从服务器下载文件 scp username@servername:/path/filename /path/filename 上传本地文件到服务器 scp /p ...
- linux 汇编 - 函数调用
Linux 汇编-函数调用 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !i ...
- 2015.12.20-2015.12.25 大论文迭代 A
进一步充实大论文内容.结构,完善一遍大论文 12.20周天,完成论文第五章总结部分,和第一章的修改 12.21周一,完成论文第二章的修改充实 12.22周二,完成论文第三章的修改充实 12.23周三, ...
- 通过offset值的设置使html元素对齐
今天是我第一次写这个随笔,为了记录我发现的一个jquery的offset的值的问题. 这个offset的值会因为页面标签是否处于隐藏状态而表现出不同的值,隐藏状态时,offset的值是相对于直接父亲的 ...
- jenkins配置邮件通知
参考: https://www.cnblogs.com/imyalost/p/8781759.html 谢谢大佬~
- [CodeForces] CF226D The table
Harry Potter has a difficult homework. Given a rectangular table, consisting of n × m cells. Each ce ...
- Switch组件
Switch组件,业务需求中经常遇到.我司的旧项目中,由于没有使用较为成熟点的组件库.自己实现了一个switch组件,但是实现的略微有些丑陋. 实现基本需求 https://jsfiddle.net/ ...
- python爬虫12 | 爸爸,他使坏,用动态的 Json 数据,我要怎么搞?
在前面我们玩了好多静态的 HTML 想必你应该知道怎么去爬这些数据了 但还有一些常见的动态数据 比如 商品的评论数据 实时的直播弹幕 岛国动作片的评分 等等 这些数据是会经常发生改变的 很多网站就会用 ...
- 远程连接工具putty与mtputty
PuTTY是一个Telnet.SSH.rlogin.纯TCP以及串行接口连接软件 官网 http://www.chiark.greenend.org.uk/~sgtatham/putty/ putty ...
- LOJ 6278 数列分块入门2
[题解] 分块.块内排序.块内二分出第一个大于等于c的数. #include<cstdio> #include<algorithm> #include<cmath> ...