首先吐槽一下这个题目的题意描述,我看了半天才明白。 下标全部都是乱标的!!!!出题者能不能规范一点下标的写法!!!!

差分约束系统

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std; int n,m,tyu;
const int maxn=;
const int INF=0x7FFFFFFF;
struct abc
{
int startt;
int endd;
int costt;
} node[maxn];
vector<abc>ljb[maxn];
int ff[maxn],summ[maxn],dist[maxn]; void spfa()
{
queue<int>Q;
while(!Q.empty()) Q.pop();
int i;
for(i=; i<=n+; i++) dist[i]=INF;
memset(ff,,sizeof(ff));
memset(summ,,sizeof(summ));
dist[]=;
ff[]=;
Q.push();
while(!Q.empty())
{
int hh=Q.front();
Q.pop();
summ[hh]++;
if(summ[hh]>n+)
{
tyu=;
break;
}
ff[hh]=;
for(i=; i<ljb[hh].size(); i++)
{
abc noww;
noww=ljb[hh][i];
if(dist[hh]+noww.costt<dist[noww.endd])
{
dist[noww.endd]=dist[hh]+noww.costt;
if(ff[noww.endd]==)
{
ff[noww.endd]=;
Q.push(noww.endd);
}
}
}
}
}
int main()
{
int i,si,ni,ki,tott;
char oi[];
while(~scanf("%d",&n))
{
if(n==) break;
scanf("%d",&m);
tott=;
for(i=; i<=n+; i++) ljb[i].clear();
for(i=; i<m; i++)
{
scanf("%d%d%s%d",&si,&ni,oi,&ki);
if(strcmp("lt",oi)==)
{
node[tott].startt=si;
node[tott].endd=si+ni+;
node[tott].costt=ki-;
ljb[si].push_back(node[tott]);
tott++;
}
else if(strcmp("gt",oi)==)
{
node[tott].startt=si+ni+;
node[tott].endd=si;
node[tott].costt=-(ki+);
ljb[si+ni+].push_back(node[tott]);
tott++;
}
}
for(i=; i<=n+; i++)
{
node[tott].startt=;
node[tott].endd=i;
node[tott].costt=;
ljb[].push_back(node[tott]);
tott++;
}
tyu=;
spfa();
if(tyu==) printf("successful conspiracy\n");
else printf("lamentable kingdom\n");
}
return ;
}

hdu 1531 King的更多相关文章

  1. hdu 1531 king(差分约束)

    King Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  2. hdu 1531(差分约束)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1531 差分约束的题之前也碰到过,刚好最近正在进行图论专题的训练,就拿来做一做. ①:对于差分不等式,a ...

  3. HDU 5642 King's Order dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5642 King's Order  Accepts: 381  Submissions: 1361   ...

  4. HDU 5644 King's Pilots 费用流

    King's Pilots 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5644 Description The military parade w ...

  5. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  6. HDU 5642 King's Order 动态规划

    King's Order 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5642 Description After the king's speec ...

  7. HDU 5640 King's Cake GCD

    King's Cake 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5640 Description It is the king's birthd ...

  8. HDU 5641 King's Phone 模拟

    King's Phone 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5641 Description In a military parade, ...

  9. hdu 5641 King's Phone

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5641 题目类型:水题 题目思路:将点x到点y所需要跨过的点存入mark[x][y]中(无需跨过其它点存 ...

随机推荐

  1. C语言之函数的声明

    函数的声明 1.函数只能定义在函数外,不能定义在函数内 2.函数不允许重名,C语言中函数没有重载 3.函数只要一经定义,就可以在任意函数中调用 注意:如果函数定义在它调用之后,那么必须在调用之前,先声 ...

  2. CSS之纯CSS画的基本图形(矩形、圆形、三角形、多边形、爱心、八卦等)

    图形包括基本的矩形.圆形.椭圆.三角形.多边形,也包括稍微复杂一点的爱心.钻石.阴阳八卦等.当然有一些需要用到CSS3的属性,所以在你打开这篇文章的时候,我希望你用的是firefox或者chrome, ...

  3. quagga源码分析--大内总管zebra

    zebra,中文翻译是斑马,于是我打开了宋冬野的<斑马,斑马>作为BGM来完成这个篇章,嘿嘿,小资一把! zebra姑且戏称它是quagga项目的大内总管. 因为它负责管理其他所有协议进程 ...

  4. 前端——CSS笔记

    CSS全称为“层叠样式表 (Cascading Style Sheets)”,它主要是用于定义HTML内容在浏览器内的显示样式,如文字大小.颜色.字体加粗等. p{ font-size:12px; c ...

  5. Ubuntu中Qt+opencv图像显示

    先抛出一个疑问,知道的希望留言解答下 (创建Application->Qt Console Application,代码与下面2.3一样,运行有时会显示图片,但大多数不显示,为什么?) 1.打开 ...

  6. kmp//呵呵!看毛片算法

    以前刚学的时候迷迷糊糊的,一看就懵圈,前几天捡起来的时候 发现还不会 于是研究了两天,自尊心严重受挫,今天的时候  突然一道灵光迸发,居然 感觉好像懂了,于是又琢磨起来  终于  我懂了  呵呵!   ...

  7. Java: MissingResourceException, "Can't find bundle for base name myMessage, locale zh_CN"

    在java中,在多语言国际化时可以用 *.java 类来作为资源文件使用. 1. 首先定义类, 类必须继承ListResourceBundle 类所在路径为: src/I18N public clas ...

  8. Windows 服务 Error 14001

    如果碰到 windows 服务安装不了或者启动不了,报14001的配置文件错误,那么 可以从.exe.config入手,我这次遇到的是配置中有中文注释导致的. 我把空行以及中文的注释去掉以后,整个世界 ...

  9. RubyMine 2016.1 下载 附注册激活码 破解版方法

    注册破解方法: 在要求输入注册的界面选择激活码,然后粘贴以下注册码: 43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0M0I0QTczWVlKIiwibGljZW5zZWVOYW1lIj ...

  10. StringBuilder跟StringBuffer

    一直以来只知道StringBuffer是线程安全的,StringBuilder是线程不安全的, 所以通常情况下使用StringBuilder,这样可以提升效率!!! 今天由于想起StringBuild ...