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. PHP 之websocket实现聊天室功能

    一.功能界面 具体的详细代码:https://github.com/yangsphp/websocket-master/tree/master 二.具体代码实现 1.前端代码如下 <!DOCTY ...

  2. CDR服装设计-用CorelDRAW排钻如何把圈摆均匀

    服装设计一直都是一个很火热的行业,也是一个比较高端的行业,随着时代的步伐,以前的人都是用手绘的方式来设计服装,现在不一样了,电脑可以说普及到了每一个家庭,让软件以更快的速度,更准确的数据来设计服装中的 ...

  3. mha0.56版本安装使用排错

    1.master_check_ssh --conf=/etc/app1.conf   这个检查就报错的我觉得百分之九十都是ssh之间连接问题.务必要保证各节点之间都可以免秘钥访问!     2.mas ...

  4. python tkinter模块 创建窗口V1.2

    先上图 代码如下 #-*-coding:utf-8-*- import os from tkinter import * root=Tk() root.title('执行窗口') "&quo ...

  5. PAT 1097. Deduplication on a Linked List (链表)

    Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated ...

  6. BUPT2017 springtraining(15) #3

    这里这里 A.签到题 #include <cstdio> double a[] = {0.4, 0.16, 0.063, 0.025, 0.010, 0.004}; int main() ...

  7. FOJ2250 不可能弹幕结界

    Problem 2250 不可能弹幕结界 Time Limit: 1000 mSec    Memory Limit : 65536 KB Problem Description 咲夜需要穿过一片弹幕 ...

  8. [cogs729] [网络流24题#5] 圆桌聚餐 [网络流,最大流,多重二分图匹配]

    建图:从源点向单位连边,边权为单位人数,从单位向圆桌连边,边权为1,从圆桌向汇点连边,边权为圆桌容量. #include <iostream> #include <algorithm ...

  9. hdu_1861_游船出租_201402282130

    游船出租 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  10. cogs 315. [POJ3255] 地砖RoadBlocks

    315. [POJ3255] 地砖RoadBlocks ★★★   输入文件:block.in   输出文件:block.out   简单对比时间限制:1 s   内存限制:128 MB Descri ...