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启动顺序为第一个,可是进系统 ...
随机推荐
- E20171229-hm
specification n. 规格; 说明书; 详述;
- git 删除本地仓库
更新: 2017/06/27 修改格式,备注mac下的命令没测试过 windows: rm .git/ mac: sudo rm -rf .git/ 没验证
- react hooks 全面转换攻略(一) react本篇之useState,useEffect
useState 经典案例: import { useState } from 'react'; function Example() { const [count, setCount] = useS ...
- 04-Vue中的动画
Vue中的动画 为什么要有动画:动画能够提高用户的体验,帮助用户更好的理解页面中的功能: -使用过渡类名 1.html <div id="app"> <input ...
- Qt实现客户端与服务器消息发送
这里用Qt来简单设计实现一个场景,即: ①两端:服务器QtServer和客户端QtClient ②功能:服务端连接客户端,两者能够互相发送消息,传送文件,并且显示文件传送进度. 环境:VS20013+ ...
- 【hdu多校联考第二场】Odd Shops
Description 这道题的题意是这道难读,大概就是给你n个商店,每个商店的重量为i的商品用ai表示,对于任意商店的a数列都是相同的,重量的范围为[1,10] 求购买方案总数为奇数的重量一共有多少 ...
- 清除WebSphere部署应用所对应的JSP缓存
Web应用部署在WebSphere Application Server v8.5后程序一般放置在<AppServer>/profiles/<profile_name>/ins ...
- EasyUI系列学习(六)-Tooltip(提示框)
一.创建组件 0.Tooltip不依赖其他组件 1.使用class加载 <a href="#" class="easyui-tooltip" title= ...
- A8ERP权限管理系统
- P2P 网络核心技术:Gossip 协议
背景 Gossip protocol 也叫 Epidemic Protocol (流行病协议),实际上它还有很多别名,比如:“流言算法”.“疫情传播算法”等. 这个协议的作用就像其名字表示的意思一样, ...