博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 4049 Tourism Planning [ 状压dp ]
阅读量:5953 次
发布时间:2019-06-19

本文共 3132 字,大约阅读时间需要 10 分钟。

Tourism Planning

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 1115    Accepted Submission(s): 482

Problem Description
Several friends are planning to take tourism during the next holiday. They have selected some places to visit. They have decided which place to start their tourism and in which order to visit these places. However, anyone can leave halfway during the tourism and will never back to the tourism again if he or she is not interested in the following places. And anyone can choose not to attend the tourism if he or she is not interested in any of the places.
Each place they visited will cost every person certain amount of money. And each person has a positive value for each place, representing his or her interest in this place. To make things more complicated, if two friends visited a place together, they will get a non negative bonus because they enjoyed each other’s companion. If more than two friends visited a place together, the total bonus will be the sum of each pair of friends’ bonuses.
Your task is to decide which people should take the tourism and when each of them should leave so that the sum of the interest plus the sum of the bonuses minus the total costs is the largest. If you can’t find a plan that have a result larger than 0, just tell them to STAY HOME.
 

 

Input
There are several cases. Each case starts with a line containing two numbers N and M ( 1<=N<=10, 1<=M<=10). N is the number of friends and M is the number of places. The next line will contain M integers Pi (1<=i<=M) , 1<=Pi<=1000, representing how much it costs for one person to visit the ith place. Then N line follows, and each line contains M integers Vij (1<=i<=N, 1<=j<=M), 1<=Vij<=1000, representing how much the ith person is interested in the jth place. Then N line follows, and each line contains N integers Bij (1<=i<=N, 1<=j<=N), 0<=Bij<=1000, Bij=0 if i=j, Bij=Bji.
A case starting with 0 0 indicates the end of input and you needn’t give an output.
 

 

Output
For each case, if you can arrange a plan lead to a positive result, output the result in one line, otherwise, output STAY HOME in one line.
 

 

Sample Input
2 1 10 15 5 0 5 5 0 3 2 30 50 24 48 40 70 35 20 0 4 1 4 0 5 1 5 0 2 2 100 100 50 50 50 50 0 20 20 0 0 0
 

 

Sample Output
5 41 STAY HOME
 

 

Source
 

 

Recommend
lcy   |   We have carefully selected several similar problems for you:            
 

 

 

13075053 2015-03-09 18:32:49 Accepted 405MS 2120K G++

 

1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #define N 15 8 9 using namespace std; 10 11 int n,m; 12 int p[N]; 13 int v[N][N]; 14 int b[N][N]; 15 int dp[N][ (1<<10) ]; 16 int ans; 17 int tot; 18 int happy[N][ (1<<10) ]; 19 20 vector
can[ (1<<10) ]; 21 22 int cal(int i,int o); 23 int ok(int k,int o); 24 25 void ini() 26 { 27 int i,j; 28 ans=0; 29 memset(dp,0,sizeof(dp)); 30 for(i=1;i<=m;i++){ 31 scanf("%d",&p[i]); 32 } 33 for(i=0;i
::iterator it =can[o].begin();it != can[o].end();it++){118 // for(k=0;k

 

转载于:https://www.cnblogs.com/njczy2010/p/4324225.html

你可能感兴趣的文章
关于“Fluent UI”或Ribbon Design报道的补充说明
查看>>
2018年终盘点:“年度爆款”的区块链真的结束了吗?
查看>>
51信用卡 Android自动埋点实践
查看>>
敏捷现状10周年调查
查看>>
PHP Session可能会引起并发问题
查看>>
AI产品开发的核心原则:以研究为核心驱动
查看>>
大规模集群中Docker镜像如何分发管理?试试Uber刚开源的Kraken
查看>>
WinDocks发布Windows版本的Docker引擎
查看>>
完美解决html中select的option不能隐藏的问题。
查看>>
推荐5大开源工具,用于开发Kubernetes项目
查看>>
制定2015年的移动开发策略
查看>>
JPA 2.2改进了易用性
查看>>
从蚂蚁金服实践入手,带你深入了解 Service Mesh
查看>>
24周年,“常青树”Delphi发布新版本10.3.1
查看>>
7. 从数据库获取数据- 从零开始学Laravel
查看>>
阿里百川码力APP监控 来了!
查看>>
使用dotenv管理环境变量
查看>>
温故js系列(11)-BOM
查看>>
Vuex学习
查看>>
bootstrap - navbar
查看>>