这个题目真是伤透脑筋了,一直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. JAXB - Unmarshalling

    A simple approach for unmarshalling an XML document consists of the creation of a JAXB context and t ...

  2. 【HTML XHTML CSS基础教程(第6版)】笔记之HTML XHTML笔记(1~6章)

      第1章 网页的构造块   1.(X)HTML有三种主要的标记类型:元素,属性,值.   2.浏览器主要通过查看文件的扩展名(.htm或.html)来得知应该按照网页的方式读取文本文件.   3.H ...

  3. 关于Extjs使用window.opener报错

    项目中使用window.opener 刷新父窗口表格,父窗口表格IE8报错, window.opener.Ext.getCmp('SalesCompanyGridPanel').getStore(). ...

  4. MFC多视图共用一文档实现

    项目过程中有定制视图的需求,具体为打开程序默认双视图并且共用一个文档.在网上找了许多类似的资料,都不尽完善.本文直接从达到目的的角度叙述,实现原理不再多说. 1.在自己的App类中定义public变量 ...

  5. 禁用Linux bash rm --force

    防止无意的Linux bash rm --force 二.禁用rm -rf 因为rm -rf 删除文件的时候,经常会不小心将系统文件或者多个有用的目录删除掉.有两种方法:1,每次删除都用-i(inte ...

  6. How to: Reading an ini config file from a batch file

    Original Link: http://almanachackers.com/blog/2009/12/31/reading-an-ini-config-file-from-a-batch-fil ...

  7. JS函数的参数对象arguments在严格模式下的限制

    在JS中,传入的函数的参数个数可以与定义函数的个数不一致,那么对于传入的实参的引用,则是arguments对象.然而改对象在严格模式和非严格模式下是由区分的: 1 在严格模式下arguments作为了 ...

  8. php常用单词语法

    header("Content-type:text/html;charset=utf-8"); 加入数组array_push($ratings_store_cop,$value); ...

  9. Unity3D--学习太空射击游戏制作(四)

    步骤七:添加声音和特效(射击声音和爆炸效果) 01:在Project窗口单机右键,选择Import Package->Custome Package,然后到资源文件目录packages浏览uni ...

  10. Sql Server 判断表或数据库是否存在

    发布:thebaby   来源:脚本学堂     [大 中 小] 本文详细介绍了,在sql server中判断数据库或表是否存在的方法,有理论有实例,有需要的朋友可以参考下,一定有帮助的.原文地址:h ...