题意:







思路:

裸的Dijkstra 爆敲一发模板

//By SiriusRen
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 2222
int f,p,c,m,xx,yy,zz,w[N],v[N],next[N],first[N],tot,dis[N],vis[N],ans,s[N];
struct Node{int now,weight;}jy;
priority_queue<Node>pq;
void add(int x,int y,int z){
w[tot]=z,v[tot]=y,next[tot]=first[x],first[x]=tot++;
}
bool operator < (Node a,Node b){
return a.weight>b.weight;
}
void Dijkstra(){
memset(dis,0x3f,sizeof(dis));
dis[1]=0;
jy.now=1,jy.weight=0;
pq.push(jy);
while(!pq.empty()){
Node t=pq.top();pq.pop();
if(vis[t.now])continue;
vis[t.now]=1;
for(int i=first[t.now];~i;i=next[i])
if(!vis[v[i]]&&dis[v[i]]>dis[t.now]+w[i]){
dis[v[i]]=dis[t.now]+w[i];
jy.now=v[i],jy.weight=dis[v[i]];
pq.push(jy);
}
}
}
int main(){
memset(first,-1,sizeof(first));
scanf("%d%d%d%d",&f,&p,&c,&m);
for(int i=1;i<=p;i++){
scanf("%d%d%d",&xx,&yy,&zz);
add(xx,yy,zz),add(yy,xx,zz);
}
Dijkstra();
for(int i=1;i<=c;i++){
scanf("%d",&xx);
if(dis[xx]<=m)
s[++ans]=i;
}
printf("%d\n",ans);
for(int i=1;i<=ans;i++)
printf("%d\n",s[i]);
}

最新文章

  1. 黄聪:C#中HtmlAgilityPack判断是否包含或不包含指定的属性或值
  2. CentOS下vm虚拟机桥接联网
  3. IOS, xib和storyboard的混用
  4. .NET跨平台:再见dnx,你好dotnet cli
  5. 数据块损坏(block corruption)
  6. SQL 基础语法(创建表空间、用户、并授予权限、数据的增删改查) --(学习笔记)[转]
  7. 设计模式之Composite(组合)模式
  8. 原生JS取代一些JQuery方法
  9. 32位Windows7上8G内存使用感受+xp 32位下使用8G内存 (转)
  10. 解决 VirtualBox 安装windows 8.1 Preview OR Server 2012 R2 Preview 错误
  11. perl 类里的函数调用其他类的函数
  12. POJ 2182/暴力/BIT/线段树
  13. html 设置页脚div一直在页面底部
  14. Ionic start 创建项目报错 Error with start undefined
  15. React Starter Kit 中文文档
  16. D. How many trees? DP
  17. [WP]BugkuCtf - pwn2
  18. 【Android基础】利用Intent在Activity之间传递数据
  19. 【TensorFlow】基于ssd_mobilenet模型实现目标检测
  20. BZOJ.3575.[HNOI2014]道路堵塞(最短路 动态SPFA)

热门文章

  1. 【DNN 系列】 MVC 分页
  2. 程序Yuan,eclipse你,会用吗?
  3. mac、windows如何强制关闭tomcat进程
  4. [POI2011]MET-Meteors 整体二分_树状数组_卡常
  5. Could not create connection to database server. Attempted reconnect 3 times. Giving up.错误
  6. 基于CC2530的ZigBee转以太网网关的设计与实现
  7. 使用ssh过程中对数据库进行update时报错
  8. Intellij Idea创建的第一个JavaWeb程序
  9. js插件---瀑布流Masonry
  10. Python3小白初体验