UVA 10896 Sending Email
这个题目真是伤透脑筋了,一直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的更多相关文章
- uva 10986 - Sending email(最短路Dijkstra)
题目连接:10986 - Sending email 题目大意:给出n,m,s,t,n表示有n个点,m表示有m条边,然后给出m行数据表示m条边,每条边的数据有连接两点的序号以及该边的权值,问说从点s到 ...
- UVa 10986 - Sending email
题目大意:网络中有n个SMTP服务器,有m条电缆将它们相连,每条电缆传输信息需要一定的时间.现在给出信息的起点和终点,计算所需的最小时间. 有权图上的单源最短路问题(Single-Source Sho ...
- UVA 10986 Sending email 最短路问题
基本的最短路问题 就是数据需要稍微处理一下.(N比较大)dijkstra也要优化.不优化应该会T: #include <map> #include <set> #include ...
- Sending e-mail with Spring MVC---reference
reference from:http://www.codejava.net/frameworks/spring/sending-e-mail-with-spring-mvc Table of con ...
- Sending e-mail with Spring MVC--转载
原文地址:http://www.codejava.net/frameworks/spring/sending-e-mail-with-spring-mvc Table of contents: 1.S ...
- 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 ...
- Spring – Sending E-Mail Via Gmail SMTP Server With MailSender--reference
Spring comes with a useful ‘org.springframework.mail.javamail.JavaMailSenderImpl‘ class to simplify ...
- Sending e-mail
E-mail functionality uses the Apache Commons Email library under the hood. You can use theplay.libs. ...
- Sending Email In .NET Core 2.0
Consider the following written in .NET Core 2.0. SmtpClient client = ) { UseDefaultCredentials = tru ...
随机推荐
- mysql同时向一个表中插入多条数据问题!!见详细
INSERT INTO `表名` (`字段1`,`字段2`,`字段3`,`字段4`) values ('数组1数据1','数组1数据2','数组1数据3','数组1数据4'), ('数组2数据1',' ...
- spark处理jsonFile
按照spark的说法,这里的jsonFile是特殊的文件: Note that the file that is offered as jsonFile is not a typical JSON f ...
- ASP.NET会员注册登录模块(MD5加密,Parameters防止SQL注入,判断是否注册)
MD5加密,Parameters防止SQL注入: protected void btnLog_Click(object sender, EventArgs e) { //获取验 ...
- C#学习笔记8:HTML和CSS基础学习笔记
<!-- 1.<P>...</P>段落标签 2.<br/>折行标签. 3.<img src="" height="*px& ...
- C#学习笔记2:Iframe框架、MD5加密
1.static void Main()的问题. static void Main(){……//代码}static void Main(string[] args){……//代码}两者的不同点?str ...
- android NDK 笔记
*************************************************华丽的分割线********************************************* ...
- 关于TouchEvent中出现异常:MessageQueue-JNI问题
Tag:MessageQueue-JNI Exception dispatching input event. Exception in MessageQueue callback: handleRe ...
- LeetCode初体验—twoSum
今天注册了大名鼎鼎的LeetCode,做了一道最简单的算法题目: Given an array of integers, return indices of the two numbers such ...
- eclipse 好用的插件安装地址集合【持续更新】
1.PropertiesEditor (编辑properties文件的插件): http://propedit.sourceforge.jp/eclipse/updates/ 2.Aptana Stu ...
- Mysql 中 like 查询存在反斜杠的解决办法
如 要查询 %\ABC\% 应该这样写, 写成四个反斜杠 like '%\\\\ABC\\\\%'