| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
傻逼们过来拷#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[510][510],ss[510],S[110],f,p,c,m,x,y,z;
bool v[510];
void findmax()
{
memset(v,0,sizeof(v));
for(int i=1;i<=f;i++)ss[i]=9999999;
ss[1]=0;
for(int i=1;i<=f;i++)
{
int ans=0,max=9999999;
for(int j=1;j<=f;j++)
{
if(v[j]==false&& ss[j]<max)
{
max=ss[j];
ans=j;
}
}
if(ans==0)return ;
v[ans]=true;
for(int j=1;j<=f;j++)
{
if(a[ans][j]!=999999 &&ss[j]>ss[ans]+a[ans][j])
ss[j]=ss[ans]+a[ans][j];
}
}
}
void Solve()
{
for(int i=1;i<=f;i++)
for(int j=1;j<=f;j++)
a[i][j]=9999999;
}
int main()
{
scanf("%d%d%d%d",&f,&p,&c,&m);
memset(a,0x3f,sizeof(a));
memset(S,0,sizeof(S));
for(int i=1;i<=p;i++)
{
scanf("%d%d%d",&x,&y,&z);
a[x][y]=a[y][x]=min(a[x][y],z);
}
findmax();
int l,num=0;
for(int i=1;i<=c;i++)
{
scanf("%d",&l);
if(ss[l]<=m) S[num++]=i;
}
printf("%d\n",num);
for(int i=0;i<num;i++) printf("%d\n",S[i]);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator