CodeForcesGym 100753E Change of Scenery
Change of Scenery
This problem will be judged on CodeForcesGym. Original ID: 100753E
64-bit integer IO format: %I64d Java class name: (Any)

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxn = ;
struct arc{
int to,cost,next;
arc(int x = ,int y = ,int z = -){
to = x;
cost = y;
next = z;
}
}e[];
int head[maxn],cnt[maxn],d[maxn],tot,N,M,K;
void add(int u,int v,int w){
e[tot] = arc(v,w,head[u]);
head[u] = tot++;
}
priority_queue<pii,vector<pii>,greater<pii>>q;
bool done[maxn];
void dijkstra(){
while(!q.empty()) q.pop();
memset(d,0x3f,sizeof d);
memset(cnt,,sizeof cnt);
q.push(pii(d[] = ,cnt[] = ));
while(!q.empty()){
int u = q.top().second;
q.pop();
if(done[u]) continue;
done[u] = true;
for(int i = head[u]; ~i; i = e[i].next){
if(d[e[i].to] > d[u] + e[i].cost){
d[e[i].to] = d[u] + e[i].cost;
cnt[e[i].to] = cnt[u];
q.push(pii(d[e[i].to],e[i].to));
}else if(d[e[i].to] == d[u] + e[i].cost)
cnt[e[i].to]++;
}
}
}
int main(){
int x,u,v,w;
while(~scanf("%d%d%d",&N,&M,&K)){
memset(head,-,sizeof head);
while(K--) scanf("%d",&x);
for(int i = tot = ; i < M; ++i){
scanf("%d%d%d",&u,&v,&w);
add(u,v,w);
add(v,u,w);
}
dijkstra();
puts(cnt[N] > ?"yes":"no");
}
return ;
}
/*
3 3 3
1 2 3
1 2 1
2 3 2
1 3 3
4 5 2
1 4
1 2 2
2 4 1
1 3 1
3 4 2
1 4 2
*/
CodeForcesGym 100753E Change of Scenery的更多相关文章
- The Google Test and Development Environment (持续更新)
最近Google Testing Blog上开始连载The Google Test and Development Environment(Google的测试和开发环境),因为blogspot被墙,我 ...
- German Collegiate Programming Contest 2015 计蒜课
// Change of Scenery 1 #include <iostream> #include <cstdio> #include <algorithm> ...
- 2015 German Collegiate Programming Contest (GCPC 15) + POI 10-T3(12/13)
$$2015\ German\ Collegiate\ Programming\ Contest\ (GCPC 15) + POI 10-T3$$ \(A.\ Journey\ to\ Greece\ ...
- 代码的坏味道(10)——发散式变化(Divergent Change)
坏味道--发散式变化(Divergent Change) 发散式变化(Divergent Change) 类似于 霰弹式修改(Shotgun Surgery) ,但实际上完全不同.发散式变化(Dive ...
- [LeetCode] Coin Change 硬币找零
You are given coins of different denominations and a total amount of money amount. Write a function ...
- input事件与change事件
输入框的change事件: 必须等到输入框失去焦点的时候才会触发,鼠标在空白的地方点一下: 输入框的input事件: 在输入内容变化的同时,实时的触发,不需要等到失去焦点.
- Change the Target Recovery Time of a Database (SQL Server) 间接-checkpoints flushcache flushcache-message
Change the Target Recovery Time of a Database (SQL Server) 间接checkpoints flushcache flushcache-mes ...
- Change Line Type in OpenCascade
Change Line Type in OpenCascade eryar@163.com 关键字KeyWords:OpenCascade,Line Aspect, Line Type 在OpenCa ...
- 华硕笔记本U盘启动系统/WinPE报错。Windows failed to start. A Recent hardware or software change might be the cause.
最近在整一台华硕笔记本,大概有5年寿命了吧,质量还行,由于系统出了问题,打算用自制U盘WinPE进去修复一下.按照个人经验,在主板设置里启用了USB启动选项,并且设置USB启动顺序为第一个,可是进系统 ...
随机推荐
- centos7的systemd
系统启动流程 POST --> Boot Sequence --> Bootloader --> kernel+initramfs(initrd) --> rootfs --& ...
- conda命令不能用的问题
在Windows下安装了Anaconda3-5.0.1-Windows-x86.exe 但是在cmd端下,打命令conda没反应 打pip显示如下错误 这是由于cmd编码为gbk的问题导致的 解决方案 ...
- [Swift通天遁地]一、超级工具-(10)使用地图视图MKMapView的相机功能实现创建三维地图
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- php+ajax+jquery实现jsonp跨域
我们有这么个html文件test.html: 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&q ...
- Android 性能优化(26)*性能工具之「Batterystats,Battery Historian」Batterystats & Battery Historian Walkthrough
Batterystats & Battery Historian Walkthrough Working with Batterystats & Battery Historian B ...
- bnu 51640 Training Plan DP
https://www.bnuoj.com/bnuoj/problem_show.php?pid=51640 dp[i][j]表示前j个数,分成了i组,最小需要多少精力. 那么,求解订票dp[i][j ...
- kali中的APT软件包处理工具(apt-get)、Debian软件包管理器(dpkg)、源代码压缩和Nessus安装实用指南
写在前面的话 能看懂此博客的朋友,深信你有一定的Kali基础了. 使用APT软件包处理工具(apt-get).Debian软件包管理器(dpkg)来维护.升级和安装自定义及第三方应用程序 APT软件包 ...
- OpenTSDB监控
OpenTSDB监控
- Java_大数值_16.5.12
如果基本的整数和浮点数精度不能满足要求,那么可以使用java.math包中的BigInteger和BigDecimal这两个类.这两个类可以处理包含任意长度数字序列的数值.BigInteger类实现了 ...
- POJ_1163_The triangle
The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 40079 Accepted: 24144 De ...