Network Saboteur
来源:互联网 发布:淘宝卖家主图视频教程 编辑:程序博客网 时间:2024/05/19 22:44
Network Saboteur
Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 69 Accepted Submission(s) : 33
Problem Description
A university network is composed of N computers. System administrators gathered information on the traffic between nodes, and carefully divided the network into two subnetworks in order to minimize traffic between parts.
A disgruntled computer science student Vasya, after being expelled from the university, decided to have his revenge. He hacked into the university network and decided to reassign computers to maximize the traffic between two subnetworks.
Unfortunately, he found that calculating such worst subdivision is one of those problems he, being a student, failed to solve. So he asks you, a more successful CS student, to help him.
The traffic data are given in the form of matrix C, where Cij is the amount of data sent between ith and jth nodes (Cij = Cji, Cii = 0). The goal is to divide the network nodes into the two disjointed subsets A and B so as to maximize the sum ∑Cij (i∈A,j∈B).
A disgruntled computer science student Vasya, after being expelled from the university, decided to have his revenge. He hacked into the university network and decided to reassign computers to maximize the traffic between two subnetworks.
Unfortunately, he found that calculating such worst subdivision is one of those problems he, being a student, failed to solve. So he asks you, a more successful CS student, to help him.
The traffic data are given in the form of matrix C, where Cij is the amount of data sent between ith and jth nodes (Cij = Cji, Cii = 0). The goal is to divide the network nodes into the two disjointed subsets A and B so as to maximize the sum ∑Cij (i∈A,j∈B).
Input
The first line of input contains a number of nodes N (2 <= N <= 20). The following N lines, containing N space-separated integers each, represent the traffic matrix C (0 <= Cij <= 10000). <br>Output file must contain a single integer -- the maximum traffic between the subnetworks. <br>
Output
Output must contain a single integer -- the maximum traffic between the subnetworks.
Sample Input
30 50 3050 0 4030 40 0
Sample Output
90#include<iostream>#include<stdio.h>#include<string.h>using namespace std;int n,ans;int a[1001],b[1001];int map[1001][1001];void dfs(int v,int colla,int collb){ int i,j,sum; if(v==n) { sum=0; for(i=1;i<=colla;i++) for(j=1;j<=collb;j++) sum+=map[a[i]][b[j]]; if(sum>ans) ans=sum; return ; } a[colla+1]=v+1; dfs(v+1,colla+1,collb); b[collb+1]=v+1; dfs(v+1,colla,collb+1);}int main(){ int i,j; while(cin>>n) { memset(map,0,sizeof(map)); memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(i=1;i<=n;i++) for(j=1;j<=n;j++) cin>>map[i][j]; ans=0; dfs(0,0,0); cout<<ans<<endl; }}
阅读全文
0 0
- Network Saboteur
- Network Saboteur
- Network Saboteur
- Network Saboteur
- Network Saboteur
- Network Saboteur
- poj 2531 Network Saboteur
- Poj 2531 Network Saboteur
- K - Network Saboteur
- POJ 2531 Network Saboteur
- poj2531 Network Saboteur
- POJ 2531 Network Saboteur
- POJ 2531 Network Saboteur
- POJ2531--Network Saboteur
- POJ-2531-Network Saboteur
- POJ 2531 Network Saboteur
- POJ 2531 Network Saboteur
- poj 2531 Network Saboteur
- Android 完美实现图片圆角和圆形(对实现进行分析)
- python 学习笔记5
- 【Loj 1282 】 Leading and Trailing 【a^b 的前3位and后三位】
- 快速幂取模
- 字符串训练03—自我实现atoi(字符串转整形) 如:“123”转换成 123 “-123” 转换成 -123
- Network Saboteur
- ORA-19625: error identifying file /home/oracle/arch1_13_949547843.dbf ORA-27037: unable to obtain fi
- Hello
- 高仿微信5.2.1主界面架构 包含消息通知
- linux的I2C驱动——移植篇
- Java在哪些方面有应用
- 数据结构二叉树
- 字符串训练04—自我实现itoa(整形转字符串) 如: 123 转换成 “123” “-123” 转换成 -123
- 1116. Come on! Let's C (20)