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)的更多相关文章

  1. POJ-2561 Network Saboteur(DFS)

    题目: A university network is composed of N computers. System administrators gathered information on t ...

  2. PKU 2531 Network Saboteur(dfs+剪枝||随机化算法)

    题目大意:原题链接 给定n个节点,任意两个节点之间有权值,把这n个节点分成A,B两个集合,使得A集合中的每一节点与B集合中的每一节点两两结合(即有|A|*|B|种结合方式)权值之和最大. 标记:A集合 ...

  3. poj2531 Network Saboteur

    Network Saboteur Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11122   Accepted: 5372 ...

  4. POJ2531Network Saboteur(DFS+剪枝)

    Network Saboteur Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10391   Accepted: 4990 ...

  5. Network Saboteur 分类: 搜索 POJ 2015-08-09 19:48 7人阅读 评论(0) 收藏

    Network Saboteur Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10147 Accepted: 4849 Des ...

  6. Network Saboteur(搜索)

    Network Saboteur POJ2531 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10351   Accept ...

  7. POJ2531——Network Saboteur(随机化算法水一发)

    Network Saboteur DescriptionA university network is composed of N computers. System administrators g ...

  8. CSU-ACM2016暑假集训训练2-DFS(C - Network Saboteur)

    C - Network Saboteur Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu ...

  9. Network Saboteur (DFS)

    题目: A university network is composed of N computers. System administrators gathered information on t ...

随机推荐

  1. Python语言之控制流(if...elif...else,while,for,break,continue)

    1.if...elif...else... number = 23 guess = int(input('Enter an integer : ')) if guess == number: prin ...

  2. 【转载】HTTP 响应头与状态码

    原文地址:https://segmentfault.com/a/1190000006689786 HTTP Response Header 响应头域允许服务器传递不能放在状态行的附加信息,这些域主要描 ...

  3. python_时间日期

    time.time()用于获取当前时间戳 从返回浮点数的时间辍方式向时间元组转换,只要将浮点数传递给如localtime之类的函数. localtime = time.localtime(time.t ...

  4. PHP操作Redis相关函数

    String数据类型 $redis->set('key','TK'); $redis->set('number','1'); //设置值 $redis->setex('key',5, ...

  5. Oracle 函数总结

    <1>=========================返回 String,其中包含有与指定的字符代码相关的字符======================== 函      数:< ...

  6. centos安装指定mysql

    mysql下载地址:http://repo.mysql.com/ nginx下载地址 我下载是这个 http://nginx.org/packages/centos/7/noarch/RPMS/ngi ...

  7. 【转载】文件上传Expected MultipartHttpServletRequest: is a MultipartResolver错误解决

    引入包commons-fileupload-*.jar,版本号可以根据项目情况调整: 在spring mvc配置文件中增加配置,文件大小限制可根据项目情况调整: <!-- 上传文件拦截,设置最大 ...

  8. 微智魔盒APP开发程序解析

    微智魔盒系统开发找崔经理l88Z.6ZZ685l.微智魔盒app开发.微智魔盒商城开发.微智魔盒软件开发,微智魔盒模式开发,微智魔盒源码开发.微智魔盒开发. @Override publicvoidr ...

  9. js 简单模板引擎

    代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" cont ...

  10. 通过git向github提交项目

    按顺序学习 https://www.cnblogs.com/forget406/p/6045499.html#top https://blog.csdn.net/xiaoputao0903/artic ...