题目链接

不知为何会在dp里呢。。。INF取小了,2Y。

 #include <cstring>
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
#define INF 1e9
int l1,l2,l3,c1,c2,c3;
int p[];
int dis[];
int in[];
int judge(int x,int y)
{
int d = p[x] - p[y];
if(d < )
d = -d;
if(d <= l1)
return c1;
if(d <= l2)
return c2;
if(d <= l3)
return c3;
return INF;
}
int main()
{
int i,n,sv,ev,w,u;
queue<int>que;
scanf("%d%d%d%d%d%d",&l1,&l2,&l3,&c1,&c2,&c3);
scanf("%d",&n);
scanf("%d%d",&sv,&ev);
for(i = ;i <= n;i ++)
scanf("%d",&p[i]);
for(i = ;i <= n;i ++)
{
dis[i] = INF;
in[i] = ;
}
dis[sv] = ;
in[sv] = ;
que.push(sv);
while(!que.empty())
{
u = que.front();
que.pop();
in[u] = ;
for(i = ;i <= n;i ++)
{
w = judge(i,u);
if(dis[i] > dis[u] + w)
{
dis[i] = dis[u] + w;
if(!in[i])
{
in[i] = ;
que.push(i);
}
}
}
}
printf("%d\n",dis[ev]);
return ;
}

URAL 1031. Railway Tickets(spfa)的更多相关文章

  1. 递推DP URAL 1031 Railway Tickets

    题目传送门 /* 简单递推DP:读题烦!在区间内的都更新一遍,dp[]初始化INF 注意:s1与s2大小不一定,坑! 详细解释:http://blog.csdn.net/kk303/article/d ...

  2. POJ 2355 Railway tickets

    Railway tickets Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2472   Accepted: 865 De ...

  3. DP+高精度 URAL 1036 Lucky Tickets

    题目传送门 /* 题意:转换就是求n位数字,总和为s/2的方案数 DP+高精度:状态转移方程:dp[cur^1][k+j] = dp[cur^1][k+j] + dp[cur][k]; 高精度直接拿J ...

  4. ural 1217. Unlucky Tickets

    1217. Unlucky Tickets Time limit: 1.0 secondMemory limit: 64 MB Strange people live in Moscow! Each ...

  5. Ural 1036 Lucky Tickets

    Lucky Tickets Time Limit: 2000ms Memory Limit: 16384KB This problem will be judged on Ural. Original ...

  6. URAL DP第一发

    列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scient ...

  7. URAL(DP集)

    这几天扫了一下URAL上面简单的DP 第一题 简单递推 1225. Flags #include <iostream> #include<cstdio> #include< ...

  8. POJ2828 Buy Tickets[树状数组第k小值 倒序]

    Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 19012   Accepted: 9442 Desc ...

  9. POJ 2828 Buy Tickets(线段树 树状数组/单点更新)

    题目链接: 传送门 Buy Tickets Time Limit: 4000MS     Memory Limit: 65536K Description Railway tickets were d ...

随机推荐

  1. HTML5学习之WebWork多线程处理(八)

    多线程技术在服务端技术中已经发展的很成熟了,而在Web端的应用中却一直是鸡肋 在新的标准中,提供的新的WebWork API,让前端的异步工作变得异常简单. 使用:创建一个Worker对象,指向一个j ...

  2. 64位Ubuntu运行32位程序时报文件不存在(No such file or Directory)的一种解决办法

    尝试在64位Ubuntu下面运行32位程序时, 一直说 文件不存在(No such file or directory), 我只想说++. 你tm说个文件格式不正确不就好了? 非得说个文件不存在! 真 ...

  3. Spring+Hibernate+Oracle中的Clob操作配置

    bean对象配置: <!-- 此处用于指定当前JDBC的实现,详见下面注解① --> <bean id="nativeJdbcExtractor" class=& ...

  4. hdu 4031 2011成都赛区网络赛A题 线段树 ***

    就是不知道时间该怎么处理,想了好久,看了别人的题解发现原来是暴力,暴力也很巧妙啊,想不出来的那种  -_-! #include<cstdio> #include<iostream&g ...

  5. linux SecureCRT ssh key认证登陆

    转自:http://blog.chinaunix.net/uid-20639775-id-3207171.html 通过SecureCRT创建key登录认证 一.生成公钥/密钥对 使用SecureCR ...

  6. PMP 第十章 项目沟通管理

    1识别干系人 2规划沟通 3发布信息 4管理干系人期望 5报告绩效 1.沟通的维度有哪些?沟通技巧有哪些? 2.规划沟通管理的目的是什么?沟通渠道的计算(重点).影响沟通技术的因素有哪些?沟通模型的步 ...

  7. flex_高度补全

    一个高度为100px, 另外一个高度自动补全当前界面下剩余的高度: <!DOCTYPE html> <html lang="en"> <head> ...

  8. DotNet 资源大全中文版,内容包括:编译器、压缩、应用框架、应用模板、加密、数据库、反编译、IDE、日志、风格指南等

    DotNet 资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列的资源整理.awesome-dotnet 是由 quozd 发起和维护.内容包括:编译器. ...

  9. 把所有css放到一个css文件的格式

    @charset "utf-8"; @import url("global.css"); @import url("common.css") ...

  10. 基于PHP以及Mysql,使用WordPress搭建站点

    1.前提环境是PHP以及Mysql以及安装配置完成,Nginx服务启动: 2.配置Mysql的初始密码:mysql安装后,默认root密码是空的,所以要设置密码: mysql -u root  mys ...