2015
04-16

# Disney’s FastPass

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?

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 Pi, Ti, FTi,Ni, Fi,1, Fi,2 … Fi,Ni-1, FiNi ,(1 <= Pi,Ni, Fi,j <=N, 0 <= FTi <= Ti <= 10^4), which means the ith interested a��raction is placed at location Pi and there are Ni locations Fi,1; Fi,2 … Fi,Ni 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.

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 Pi, Ti, FTi,Ni, Fi,1, Fi,2 … Fi,Ni-1, FiNi ,(1 <= Pi,Ni, Fi,j <=N, 0 <= FTi <= Ti <= 10^4), which means the ith interested a��raction is placed at location Pi and there are Ni locations Fi,1; Fi,2 … Fi,Ni 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.

2
4 5 2
1 2 8
2 3 4
3 4 19
4 1 6
2 4 7
2 25 18 1 3
4 12 6 1 3
4 6 2
1 2 5
1 4 4
3 1 1
3 2 1
3 4 1
2 4 10
2 8 3 1 4
4 8 3 1 2

Case #1: 53
Case #2: 14

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

#define INF 0x3f3f3f3f
typedef long long LL;
const int N=55;

int pos[N],T[N],FT[N],pass[N];
int dis[N][1<<8][1<<8];
int n,m,K;

void floyed()
{
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)
{
}
}
}
}
int fun()
{
int ans=INF;
dis[1][0][0]=0;
for(int s1=0;s1<(1<<K);s1++)
{
for(int s2=0;s2<(1<<K);s2++)
{
for(int i=1;i<=n;i++)
{
int now=dis[i][s1][s2];

if(now==INF) continue;

for(int j=0;j<K;j++) if((s2&(1<<j))==0)
{
int &nxt=dis[pos[j]][ s1|pass[ pos[j] ] ][s2^(1<<j)];

}
for(int j=1;j<=n;j++)
{
int &nxt=dis[j][s1|pass[j]][s2];
}
}
}
}
return ans;
}
int main()
{
int t,t_cnt=0;
scanf("%d",&t);
while(t--)
{
memset(dis,0x3f,sizeof(dis));
memset(pass,0,sizeof(pass));

scanf("%d%d%d",&n,&m,&K);
for(int i=0;i<m;i++)
{
int a,b,c; scanf("%d%d%d",&a,&b,&c);
}

floyed();

for(int i=0;i<K;i++)
{
scanf("%d%d%d",&pos[i],&T[i],&FT[i]);
int num; scanf("%d",&num);
for(int j=0;j<num;j++)
{
int tmp; scanf("%d",&tmp);
pass[tmp]|=(1<<i);
}
}
printf("Case #%d: %d\n",++t_cnt,fun());
}
return 0;
}


1. 第2题，TCP不支持多播，多播和广播仅应用于UDP。所以B选项是不对的。第2题，TCP不支持多播，多播和广播仅应用于UDP。所以B选项是不对的。