这个题目真是伤透脑筋了,一直RE,连着改了好几个版本,又是spfa,又是单调队列dijkstra+单调队列,总是不过,后来发现M开小了,双向边应该开m的两倍,悲剧啊!!!以后不管怎样,数组一定要尽量开大点。

折磨的真是痛苦,不过发现了一样好东西,http://uvatoolkit.com/problemssolve.php

uva一个测试工具,输入数据能够给出正确结果,以后不用辛苦到网上找AC代码了,直接输入结果。

 #include <cstdio>
#include <cstring>
#include <queue>
#include <cstdlib>
#define N 20010
#define M 100010
#define INF 0x0f0f0f0f using namespace std;
typedef pair<int,int> pii; int next[M],first[M],to[M],w[M];
int d[N],p; void add(int u,int v,int t)
{
to[p] = v;
w[p] = t;
next[p] = first[u];
first[u] = p++;
} int main(void)
{
int T;
for(int t = scanf("%d",&T); t <= T; t++)
{
priority_queue <pii, vector<pii>, greater<pii> > q;
p = ;
memset(first,-,sizeof(first));
int sr,ta,n,m,u,v,c;
scanf("%d%d%d%d",&n,&m,&sr,&ta);
for(int i=;i<m;i++)
{
scanf("%d%d%d",&u,&v,&c);
add(u,v,c);
add(v,u,c);
}
memset(d,0x0f,sizeof(d));
d[sr] = ;
q.push(make_pair(d[sr],sr));
while(!q.empty())
{
pii u = q.top();q.pop();
int x = u.second;
if(u.first != d[x])
continue;
for(int e = first[x]; e != -; e = next[e])
if(d[to[e]] > d[x]+w[e])
{
d[to[e]] = d[x] + w[e];
q.push(make_pair(d[to[e]],to[e]));
}
}
printf("Case #%d: ",t);
if(d[ta]==INF)
puts("unreachable");
else printf("%d\n",d[ta]);
}
return ;
}

UVA 10896 Sending Email的更多相关文章

  1. uva 10986 - Sending email(最短路Dijkstra)

    题目连接:10986 - Sending email 题目大意:给出n,m,s,t,n表示有n个点,m表示有m条边,然后给出m行数据表示m条边,每条边的数据有连接两点的序号以及该边的权值,问说从点s到 ...

  2. UVa 10986 - Sending email

    题目大意:网络中有n个SMTP服务器,有m条电缆将它们相连,每条电缆传输信息需要一定的时间.现在给出信息的起点和终点,计算所需的最小时间. 有权图上的单源最短路问题(Single-Source Sho ...

  3. UVA 10986 Sending email 最短路问题

    基本的最短路问题 就是数据需要稍微处理一下.(N比较大)dijkstra也要优化.不优化应该会T: #include <map> #include <set> #include ...

  4. Sending e-mail with Spring MVC---reference

    reference from:http://www.codejava.net/frameworks/spring/sending-e-mail-with-spring-mvc Table of con ...

  5. Sending e-mail with Spring MVC--转载

    原文地址:http://www.codejava.net/frameworks/spring/sending-e-mail-with-spring-mvc Table of contents: 1.S ...

  6. Sending Email from mailx Command in Linux Using Gmail’s SMTP

    The mailx or mail command in Linux is still providing service for guys like me, especially when we n ...

  7. Spring – Sending E-Mail Via Gmail SMTP Server With MailSender--reference

    Spring comes with a useful ‘org.springframework.mail.javamail.JavaMailSenderImpl‘ class to simplify ...

  8. Sending e-mail

    E-mail functionality uses the Apache Commons Email library under the hood. You can use theplay.libs. ...

  9. Sending Email In .NET Core 2.0

    Consider the following written in .NET Core 2.0. SmtpClient client = ) { UseDefaultCredentials = tru ...

随机推荐

  1. C# 接口的隐式与显示实现【转】

    以前在用到接口时,从来没注意到接口分为隐式实现与显示实现.昨天在浏览博客时看到相关内容,现在根据自己的理解记录一下,方便日后碰到的时候温习温习.通俗的来讲,“显示接口实现”就是使用接口名称作为方法名的 ...

  2. asp生成静态HTML(动态读取)

    这样的代码多用于我们没有实现设计生成静态的功能,但又想临时将一些动态页面生成静态的,直接获取动态内容并保存为静态的 复制代码代码如下: <!--#include file="admin ...

  3. SQL Server2008数据库如何改名

    未使用的数据库改名比较方便,找到你要更改的数据库,右键选择[重命名]. 2 然后将你想要更改的名字写好,然后点击一下旁边的空白栏. 3 然后你就发现数据库的名称已经改好了. END 使用中的数据库   ...

  4. vs2010开发android的准备工作

    安装 Mono for Android for Visual Studio 2010 需要下面4个步骤: 安装 JDK 安装 Android SDK 配置模拟器 安装 Mono for Android ...

  5. Swift学习的新工具---REPL

    从xcode6.1开始,苹果官方提供了一个新的辅助开发swift的工具,即repl(read eval print loop) OS X Yosemite系统下,打开终端应用程序,输入swift: 如 ...

  6. OC班级类

    // // MyClass.h // OC2_班级类 // // Created by zhangxueming on 15/6/12. // Copyright (c) 2015年 zhangxue ...

  7. SVG实现描边动画

    说起SVG,我是恨它又爱它,恨它是因为刚开始接触的时候自己傻B地想用代码去写它,其实在web上我们用它做交互也只是用了几个常用的特性而已,其他的标签知道这么一回事就成了,其实说白了它就是一种图片格式, ...

  8. HDU 4764 Stone(博弈)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4764 题目大意:Tang和Jiang玩石子游戏,给定n个石子,每次取[1,k]个石子,最先取完的人失败 ...

  9. “Assign Random Colors” is not working in 3ds Max 2015

    Go to Customize -> Preferences…-> General (tab) Uncheck “Default to By Layer for New Nodes”

  10. <<深入Java虚拟机>>-虚拟机类加载机制-学习笔记

    类加载的时机 遇到new.getstatic.putstatic或invokestatic这4个字节码指令时,如果类没有进行过初始化,则需要先触发其初始化.生成这4条指令最常见的Java场景是:使用n ...