hdu 1531 King
首先吐槽一下这个题目的题意描述,我看了半天才明白。 下标全部都是乱标的!!!!出题者能不能规范一点下标的写法!!!!
差分约束系统
#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的更多相关文章
- hdu 1531 king(差分约束)
King Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- hdu 1531(差分约束)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1531 差分约束的题之前也碰到过,刚好最近正在进行图论专题的训练,就拿来做一做. ①:对于差分不等式,a ...
- HDU 5642 King's Order dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5642 King's Order Accepts: 381 Submissions: 1361 ...
- HDU 5644 King's Pilots 费用流
King's Pilots 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5644 Description The military parade w ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDU 5642 King's Order 动态规划
King's Order 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5642 Description After the king's speec ...
- 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 ...
- HDU 5641 King's Phone 模拟
King's Phone 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5641 Description In a military parade, ...
- hdu 5641 King's Phone
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5641 题目类型:水题 题目思路:将点x到点y所需要跨过的点存入mark[x][y]中(无需跨过其它点存 ...
随机推荐
- Android开发学习——自定义View
转载自: http://blog.csdn.net/xmxkf/article/details/51454685 本文出自:[openXu的博客]
- CSS倒影
前面的话 CSS倒影目前只有chrome和safari浏览器支持,且需要添加-webkit-前缀.本文将详细介绍CSS倒影box-reflect 语法 -webkit-box-reflect 初始 ...
- Oracle wm_concat(列转行函数)实际使用
接触到了一个开发需求.其中是要把NC单据表体行的字段拼成一个字符串.例如: id name work age 1 王一 搬运工 20 2 李二 清洁工 21 3 张三 洗脚工 22 出现结果字符串为: ...
- GourdScan & sqlmapapi
0x01 Windows下配置GourdScan 0x0101 GourdScan项目地址:https://github.com/code-scan/GourdScan PHP环境 + ...
- IOS GCD使用实例大全
GCD是大家在IOS开发过程中经常使用的一种多线程管理机制.原理这里就不多说了,大家关心的大部分都是它的使用,下面主要介绍GCD的主要方法及其实例. 1.认识主队列,感受串行队列的运行,运行结果打印的 ...
- JS代码:设为首页 加入收藏
// JavaScript Document // 加入收藏 <a onclick="AddFavorite(window.location,document.title)" ...
- C# asp.net PhoneGap html5
很久没写博客,今天自己写一篇吧.来谈一谈c# PhoneGap,html5 与asp.net.能搜到这篇博客就说明你是一位.net开发者,即将或者正在从事移动开发. 大家可能都有疑,我是一名.net开 ...
- jquery css hover
<script type="text/javascript"> $(function () { $("#<%=btnSubmit.ClientID%&g ...
- Tomcat 6 跨域的支持
1.添加2个jar包 这个我是自己保存在云端的 cors-filter-1.7.jar java-property-utils-1.9.jar tomcat7以后自动支持 2.tomcat 下面的we ...
- 前端开发中的一些js小技巧
1.获取某个月的天数 function getDate (year, month) { return new Date(year, month + 1, 0).getDate(); } 2.获取变量类 ...