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 ...
随机推荐
- 从CSDN转到cnblogs了
之前一直用的CSDN的博客,网站卡慢经常出问题,发布文章要审核,连修改几个标点符号也要审核,这些我都忍了,毕竟之前发的文章舍不得弃掉. 现在竟然无故封禁我的博客?请问我写的都是技术文章,有哪点违反规定 ...
- privot函数使用
语法: table_source PIVOT( 聚合函数(value_column) FOR pivot_column IN(<column_list>) ) 将列转化为行 写个小示例 : ...
- 让System.Drawing.Bitmap可以在linux运行
.net core的bitmap使用的是以下类库,但无法在linux运行 https://github.com/CoreCompat/CoreCompat 在linux运行需要安装runtime.li ...
- Nginx +tomcat 实现负载均衡集群
一. 工具 nginx-1.8.0 apache-tomcat-6.0.33 二. 目标 实现高性能负载均衡的Tomcat集群: 三. 步骤 1.首先下载Nginx ...
- ModelBinder 请求容错性
代码 //using System.Web.Mvc; public class TrimToDBCModelBinder : DefaultModelBinder { public override ...
- 4.Linux的进程
4.1 Linux的进程 4.1.1 进程的概述 有关进程的一些基本概念: 1.什么是进程: 当程序被触发后,执行者的权限与属性.程序的程序代码与所需的数据都会被加载到内存中,操作系统并给予这个内存内 ...
- IE低版本和高级浏览器对文本输入事件兼容
1 一般 使用oninput 事件可以监控文本输入事实触发 2 兼容需要使用onpropertychange . 3 兼容写法 var evenInput=DOM元素.oninput || DOM ...
- Oracle query that count connections by minute with start and end times provided
数据结构类似 SQL> select * from t; B E N ----------------- ------------ ...
- Qt Creator 中文乱码问题
一. Qt 4 乱码问题 解决方案 1. 在Qt 中 快捷菜单选项功能中 Edit(编辑) --> Select Encoding...(选择编码) 选择载入(显示)编码和储存编码,要解决中文 ...
- Django CBV视图解决csrf认证
urls.py from django.conf.urls import url from appxx import views urlpatterns = [ url(r"^$" ...