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

差分约束系统

#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. js操作

    1.1.直接传入Javascript代码,定位元素 js可以点击页面上不显示暂时隐藏(比如下拉列表),但是html文件中存在的属性 WebDriver driver = new FirefoxDriv ...

  2. bzoj3504: [Cqoi2014]危桥 网络流

    一种网络流建图的思路吧,改天最好整理一波网络流建图思路 #include <bits/stdc++.h> using namespace std; int n,h,t,a1,a2,an,b ...

  3. VUGEN错误处理函数--lr-continue-on-error

    void lr-continue-on-error(int value);value是脚本运行出错时的取值,具体取值与相应值得含义如下表,在具体使用时,可以取常量名或者常量值代表. 1.设置,选择co ...

  4. 深入.NET平台和C#编程

    第一章  深入.NET框架 1.Microsoft.NET框架概述: 1).NET介绍 2)为什么需要.NET框架 通过如下两个问题说明为什么需要.NET框架 01,C#程序可以再不同平台(PDA,P ...

  5. 啥数据类型set补充、深浅拷贝与函数

    #s1 = {1,2,3,1} """ s2 = ([2,5,6]) print(s1) s1.add(5) #添加元素"5" print(s1) s ...

  6. Latex 使用小技巧

    Latex引用多篇参考文献 连续引用参考文献时中间中破折号连起来:[1,2,3,4]—>[1-4] 这是只需要在文档开始加入下面语句命令: \usepackage[numbers,sort&am ...

  7. 面试题-Java基础-布局管理器

    1.什么是布局管理器? 布局管理器用来在容器中组织组件.

  8. noip 2016 提高组题解

    前几天写的那个纯属搞笑.(额,好吧,其实这个也不怎么正经) 就先说说day2吧: T1:这个东西应该叫做数论吧. 然而我一看到就照着样例在纸上推了大半天(然而还是没有看出来这东西是个杨辉三角) 然后就 ...

  9. 【Java】ArrayList 的 toArray() 方法抛出 ClassCastException 异常

    第一次用这个方法,结果冒出个莫名其妙的异常来: String[] names = (String[]) mTags.toArray(); 结果会抛出 java.lang.ClassCastExcept ...

  10. AndroidStudio0.5.2 BUG 导致 menu 菜单键崩溃

    郁闷了半天,今天发现一点击手机 menu 键应用就崩溃了,记得之前都是好好的,调试了半天代码还是搞不定,于是网上google了一番,发现仅国外有一两篇文章有提到类似问题,据说是 0.5.2 版本的 B ...