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 ...
随机推荐
- Build Tool-自动化构建工具
输入:工程文件+编译说明文件: 处理:自动化构建工具+编译器: 输出:可执行文件. 相对于手动编译. Historically, build automation was accomplished t ...
- js 获取 checkbox[] 值
$("#btnAdd1").click(function () { console.log($("form").serialize()); var checkb ...
- Split()函数
最近遇到一个有趣的问题关于使用Split函数 ,该函数能够根据传递的参数拆分,并返回一个string的数组. 贴出一个奇怪的例子 using System; using System.Collecti ...
- CWnd* pParent
Dlg(CWnd* pParent = NULL)的意思是:构造函数.创建对象时第一个调用的地方.CWnd* pParent=NULL是构造的参数,可以不传入,默认为NULL 构造函数(constru ...
- 用 ilasm 反编译、修改.net dll文件
有些.net dll我们没有源码,如果要修改某些东西,可以用ilasm.exe反编译为il代码,修改后再编译回dll ilasm通常放在以下路径 C:\Windows\Microsoft.NET\Fr ...
- HTML5易漏知识点锦集
本文通过对w3schoolHTML5基础教程,整理出比较常见的却又容易遗忘或者忽略的HTML5相关知识点.本文的标题顺序与w3school中的HTML5基础教程标题顺序保持一致.适合翻阅和复习. 1. ...
- jquery 对 table 的操作
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta ...
- [C#] Linq 动态条件查询
应用背景:以货品为例,在基础数据中配置货品的判断规则,要根据这个规则筛选出符合条件的集合. 创建货品类 public class Product { public string Name { get; ...
- UVA1001 Say Cheese(Dijkstra或Floyd)
题目链接:UVA1001 题意:在一个巨大奶酪中的A要以最短的时间与B相遇.在奶酪中走一米的距离花费的时间是10s,而奶酪中有许多洞,穿过这些洞的时间是0s.给出A.B以及各个洞的坐标,求最短的时间. ...
- copy contents of file with variable number in Matlab
input : transient.case output: transient_1.case, transient_2.case, transient_3.case ... ************ ...