博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 4114 Disney's FastPass 状压dp
阅读量:5993 次
发布时间:2019-06-20

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

Disney's FastPass

Time Limit: 20 Sec  Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=4114

Description

Disney's FastPass is a virtual queuing system created by the Walt Disney Company. First introduced in 1999 (thugh the idea of a ride reservation system was first introduced in world fairs), Fast-Pass allows guests to avoid long lines at the attractions on which the system is installed, freeing them to enjoy other attractions during their wait. The service is available at no additional charge to all park guests.
--- wikipedia

Disneyland is a large theme park with plenties of entertainment facilities, also with a large number of tourists. Normally, you need to wait for a long time before geting the chance to enjoy any of the attractions. The FastPass is a system allowing you to pick up FastPass-tickets in some specific position, and use them at the corresponding facility to avoid long lines. With the help of the FastPass System, one can arrange his/her trip more efficiently.
You are given the map of the whole park, and there are some attractions that you are interested in. How to visit all the interested attractions within the shortest time?

 

Input

The first line contains an integer T(1<=T<=25), indicating the number of test cases.
Each test case contains several lines.
The first line contains three integers N,M,K(1 <= N <= 50; 0 <= M <= N(N - 1)/2; 0 <= K <= 8), indicating the number of locations(starting with 1, and 1 is the only gate of the park where the trip must be started and ended), the number of roads and the number of interested attractions.
The following M lines each contains three integers A,B,D(1 <= A,B <= N; 0 <= D <= 10^4) which means it takes D minutes to travel between location A and location B.
The following K lines each contains several integers P
i, T
i, FT
i,N
i, F
i,1, F
i,2 ... F
i,Ni-1, F
iNi ,(1 <= P
i,N
i, F
i,j <=N, 0 <= FT
i <= T
i <= 10^4), which means the ith interested araction is placed at location Pi and there are Ni locations F
i,1; F
i,2 ... F
i,N
i where you can get the FastPass for the ith attraction. If you come to the ith attraction with its FastPass, you need to wait for only FTi minutes, otherwise you need to wait for Ti minutes.
You can assume that all the locations are connected and there is at most one road between any two locations.
Note that there might be several attrractions at one location.

Output

For each test case in the input, print one line: "Case #X: Y", where X is the test case number (starting with 1) and Y is the minimum time of the trip.

 

Sample Input

24 5 21 2 82 3 43 4 194 1 62 4 72 25 18 1 34 12 6 1 34 6 21 2 51 4 43 1 13 2 13 4 12 4 102 8 3 1 44 8 3 1 2

Sample Output

Case #1: 53 Case #2: 14

HINT

 

题意

 游戏园里有N个区域,有M条边连接这N个区域,有K个要访问的景点。对于每个景点告诉你这个景点所在的区域,要访问这个景点需要等待一定时间,如果没有 FastPass,等待时间有Ti,否则等待时间为FTi,接下来的Ni,表示有Ni个区域可以得到这个景点的FastPass,问从区域1出发,再回到 区域1所需要的最少时间。

题解:

状态压缩dp

http://blog.csdn.net/shiqi_614/article/details/11265439

代码:

 

//qscqesze#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef long long ll;using namespace std;//freopen("D.in","r",stdin);//freopen("D.out","w",stdout);#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)#define maxn 100#define mod 10007#define eps 1e-9int Num;char CH[20];//const int inf=0x7fffffff; //нчоч╢Сconst int inf=0x3f3f3f3f;/*inline void P(int x){ Num=0;if(!x){putchar('0');puts("");return;} while(x>0)CH[++Num]=x%10,x/=10; while(Num)putchar(CH[Num--]+48); puts("");}*/inline ll read(){ ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}inline void P(int x){ Num=0;if(!x){putchar('0');puts("");return;} while(x>0)CH[++Num]=x%10,x/=10; while(Num)putchar(CH[Num--]+48); puts("");}//**************************************************************************************int dis[maxn][maxn];int dp[maxn][1<<8][1<<8];int pas[1<<8];int ans;int t[maxn],ft[maxn],pos[maxn];int n,m,k;void init(){ ans=inf; memset(dp,0x3f,sizeof(dp)); memset(dis,0x3f,sizeof(dis)); memset(pas,0,sizeof(pas)); }void flyod(){ for(int k=1;k<=n;k++) { for(int i=1;i<=n;i++) { if(i!=k) for(int j=1;j<=n;j++) { if(j!=i&&j!=k) dis[i][j]=min(dis[i][k]+dis[k][j],dis[i][j]); } } }}void solve() { dp[1][0][0]=0; for(int s1=0;s1<(1<

 

你可能感兴趣的文章
时光易逝,我懂你心
查看>>
《极限特工》系列IP启动 系列新作将在中国取景
查看>>
统计局:2018年全国社会消费品零售总额超38万亿元
查看>>
甘肃基层藏族女干部为村民解难事 扶贫扶智“少闲人”
查看>>
前端入门需要收藏的各种最新技术中文文档地址
查看>>
2019年别离职、别创业、别投资,收藏好这些热点好好干!
查看>>
Spring bean 作用域笔记
查看>>
Vary Admin:基于Vue.js的后台管理模板
查看>>
SpringCloud 总览
查看>>
PostgreSQL构建通用标签系统
查看>>
Oracle中如何导出存储过程、函数、包和触发器的定义语句?如何导出表的结构?如何导出索引的创建语句?...
查看>>
Visual Studio调试之避免单步跟踪调试模式
查看>>
奥迪坚:移动办公有“连接”更高效
查看>>
求数组的最大子数组值和最长公共子序列问题
查看>>
应用服务器优化技术
查看>>
相约珠海航展,用VR共享炫舞蓝天
查看>>
CentOS时间同步
查看>>
Python破解wifi
查看>>
Android--使用VideoView播放视频
查看>>
想要吸睛并进化为王者,做AR&VR得来这里!
查看>>