poj2531 Network Saboteur
来源:互联网 发布:风险矩阵法 编辑:程序博客网 时间:2024/05/16 16:19
做这题算是张见识了,随机化算法,随机啊!!!坑爹呢有木有?
code:
#include <set>#include <map>#include <ctime>#include <queue>#include <cmath>#include <stack>#include <limits>#include <vector>#include <bitset>#include <string>#include <cstdio>#include <cstring>#include <fstream>#include <string.h>#include <iostream>#include <algorithm>#define ls rt<<1#define rs rt<<1|1#define Si set<int>#define LL long long#define pb push_back#define PS printf(" ")#define Vi vector<int>#define LN printf("\n")#define SD(a) scanf("%d",&a)#define PD(a) printf("%d",a)#define SET(a,b) memset(a,b,sizeof(a))#define FF(i,a) for(int i(0);i<(a);i++)#define FD(i,a) for(int i(a);i>=(1);i--)#define FOR(i,a,b) for(int i(a);i<=(b);i++)#define FOD(i,a,b) for(int i(a);i>=(b);i--)#define readf freopen("input.txt","r",stdin)#define writef freopen("output.txt","w",stdout)const int maxn = 21;const int INF = 0x3fffffff;const int BigP = 99991;const int dx[] = {0,1,0,-1};const int dy[] = {1,0,-1,0};const double pi = acos(-1.0);using namespace std;int N,w[maxn][maxn];bool subset[maxn];int main(){ SD(N); FOR(i,1,N) FOR(j,1,N) SD(w[i][j]); int sum=0,maxx=0; int times=100000; while(times--){ int x=rand()%N+1; subset[x]=!subset[x]; FOR(i,1,N){ if(subset[i]!=subset[x]) sum+=w[i][x]; if(i!=x && subset[i]==subset[x]) sum-=w[i][x]; } maxx=max(sum,maxx); } PD(maxx);LN;return 0;}
- poj2531 Network Saboteur
- POJ2531--Network Saboteur
- POJ2531:Network Saboteur
- poj2531 Network Saboteur
- POJ2531.Network Saboteur
- poj2531 Network Saboteur
- POJ2531-Network Saboteur
- POJ2531 Network Saboteur dfs
- POJ2531——Network Saboteur
- POJ2531——Network Saboteur
- poj2531(dfs)Network Saboteur
- poj2531——Network Saboteur
- poj2531——Network Saboteur(dfs)
- POJ2531 Network Saboteur DFS组合问题 || 随机算法
- POJ2531-Network Saboteur-暴力枚举+记忆化/dfs/随机化乱搞
- poj2531--Network Saboteur(搜索练习7-dfs或随机算法)
- POJ2531 Network Saboteur DFS 或 无向图的最大割
- Network Saboteur
- MobclickAgent——友盟用户分析工具
- shell读取参数,并设置默认值
- 什么是流程控制,如何看懂一个程序
- 贪心算法 - 最小生成树 Prim算法
- 一篇不错的讲解Java异常的文章
- poj2531 Network Saboteur
- VMware虚拟机三种网络模式的区别
- 如何学习---理关系,找异同
- C++ 虚函数表解析
- 缓存设计介绍
- javascript定时器
- 递归显示指定文件夹下面的文件
- JVM 栈帧
- Javascript:谈谈JS的全局变量跟局部变量