Change of Scenery

Time Limit: 10000ms
Memory Limit: 262144KB

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的更多相关文章

  1. The Google Test and Development Environment (持续更新)

    最近Google Testing Blog上开始连载The Google Test and Development Environment(Google的测试和开发环境),因为blogspot被墙,我 ...

  2. German Collegiate Programming Contest 2015 计蒜课

    // Change of Scenery 1 #include <iostream> #include <cstdio> #include <algorithm> ...

  3. 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\ ...

  4. 代码的坏味道(10)——发散式变化(Divergent Change)

    坏味道--发散式变化(Divergent Change) 发散式变化(Divergent Change) 类似于 霰弹式修改(Shotgun Surgery) ,但实际上完全不同.发散式变化(Dive ...

  5. [LeetCode] Coin Change 硬币找零

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  6. input事件与change事件

    输入框的change事件: 必须等到输入框失去焦点的时候才会触发,鼠标在空白的地方点一下: 输入框的input事件: 在输入内容变化的同时,实时的触发,不需要等到失去焦点.

  7. 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 ...

  8. Change Line Type in OpenCascade

    Change Line Type in OpenCascade eryar@163.com 关键字KeyWords:OpenCascade,Line Aspect, Line Type 在OpenCa ...

  9. 华硕笔记本U盘启动系统/WinPE报错。Windows failed to start. A Recent hardware or software change might be the cause.

    最近在整一台华硕笔记本,大概有5年寿命了吧,质量还行,由于系统出了问题,打算用自制U盘WinPE进去修复一下.按照个人经验,在主板设置里启用了USB启动选项,并且设置USB启动顺序为第一个,可是进系统 ...

随机推荐

  1. PCB 漏加阻抗条的臆想(转)

    阻抗条,我对你是有感情的,这你一定要相信我! 否则,不会在之前的每一次拼板,都不忘拥你入Panel之怀. 自做CAM开始,已记不清我们曾有多少次不期而遇, 我们一同迎接朝阳,送走晚霞,凝望窗外如洗的月 ...

  2. [Swift通天遁地]一、超级工具-(12)使用Toaster制作简短提示语的吐司窗口

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  3. 乐搏讲自动化测试- Python自动化测试前景怎么样(4)

    Python言语还能够写爬虫,但仅仅只是爬虫的入门罢了.通过Python入门爬虫比较简略易学,不需要在一开始把握太多太根底太底层的常识就能够很快上手,而且很快能够做出成果,十分合适小白一开始想做出点看 ...

  4. shell set理解

    在spark bin下面load-spark-env.sh脚本里,有以下语句: if [ -f "${user_conf_dir}/spark-env.sh" ]; then # ...

  5. 1619. [HEOI2012]采花

    1619. [HEOI2012]采花 ★★☆   输入文件:1flower.in   输出文件:1flower.out   简单对比 时间限制:5 s   内存限制:128 MB [题目描述] 萧薰儿 ...

  6. Django--2、form表单

    django中定义form表单的优势 HTML中提交后,若数据出现错误,返回的页面中仍然可以保留之前输入的数据. 通过校验规则可以方便的限制字段条件并校验. 在Django中建个form表单 先要确定 ...

  7. Python学习日记之字典深复制与浅复制

    Python中通过copy模块有两种复制(深复制与浅复制) copy 浅复制 复制时只会复制父对象,而不会复制对象的内部的子对象. deepcopy 深复制 复制对象及其子对象 因此,复制后对原dic ...

  8. MySql 1248 - Every derived table must have its own alias

    执行一个sql语句,报错:1248 - Every derived table must have its own alias 提示说每一个衍生出来的表,必须要有自己的别名 执行子查询的时候,外层查询 ...

  9. View Programming Guide for iOS

    https://developer.apple.com/library/archive/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/Wi ...

  10. #NOIP前数学知识总结

    我好菜啊…… 欧拉函数 欧拉函数φ(n),是小于n且和n互质的正整数(包括1)的个数. 性质: 1.对于质数n: φ(n)=n-1 2..对于n=pk φ(n)=(p-1)*pk-1 3.积性函数的性 ...