zoj 2770 Burn the Linked Camp 差分约束
来源:互联网 发布:手机身份证读卡器软件 编辑:程序博客网 时间:2024/05/03 00:54
最近状态太散漫,一天才写了这一题,很基础的差分约束,直接写出关系式即可。注意边数开大点
/*author:jxylang:C/C++university:China,Xidian University**If you need to reprint,please indicate the source***/#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <queue>#define INF 1E9using namespace std;int Dis[1005];int U[100005];int next[100005];int W[100005];int cnt;int first[1005];int n,m;int add(int v,int u,int w){ next[cnt]=first[v]; first[v]=cnt; U[cnt]=u; W[cnt]=w; cnt++;}bool inq[1005];int dq[1005];bool spfa(int v){ memset(Dis,63,sizeof(Dis)); memset(inq,0,sizeof(inq)); memset(dq,0,sizeof(dq)); queue<int> q; q.push(v); Dis[v]=0; int i,u,now,t; while(!q.empty()) { v=q.front();q.pop(); inq[v]=0;dq[v]++; if(dq[v]>=n)return 1; for(i=first[v];i!=-1;i=next[i]) { u=U[i]; t=Dis[v]+W[i]; if(t>=Dis[u])continue; Dis[u]=t; if(inq[u])continue; inq[u]=1; q.push(u); } } return 0;}int main(){ while(~scanf("%d%d",&n,&m)) { cnt=0; memset(first,-1,sizeof(first)); int i,v,u,s; for(i=1;i<=n;i++) { scanf("%d",&s); add(i-1,i,s); add(i,i-1,0); } for(i=0;i<m;i++) { scanf("%d%d%d",&u,&v,&s); add(v,u-1,-s); } if(spfa(n))printf("Bad Estimations\n"); else printf("%d\n",-Dis[0]); }}
- zoj 2770 Burn the Linked Camp 差分约束
- zoj 2770 Burn the Linked Camp 差分约束系统
- ZOJ 2770 Burn the Linked Camp 差分约束系统
- 【ZOJ】2770 Burn the Linked Camp 差分约束
- zoj 2770 Burn the Linked Camp 【差分约束】
- ZOJ 2770 Burn the Linked Camp 差分约束
- ZOJ 2770--Burn the Linked Camp 【差分约束】
- zoj 2770 Burn the Linked Camp 差分约束系统
- ZOJ 2770 Burn the Linked Camp 差分约束
- Zoj 2770 Burn the Linked Camp 差分约束
- zoj--2770--Burn the Linked Camp(差分约束)
- ZOJ 2770 Burn the Linked Camp【差分约束 SPFA】
- ZOJ 2770- Burn the Linked Camp 差分约束
- ZOJ 2770 Burn the Linked Camp(差分约束)
- zoj Burn the Linked Camp(差分约束)
- ZOJ 2770 Burn the Linked Camp 差分约束 ZOJ排名第一~
- ZOJ 2770 Burn the Linked Camp(最短路+SPFA+差分约束系统)
- ZOJ 2770 Burn the Linked Camp( 差分约束啊 )
- SecureCRT 用来当串口工具的设置
- android剪切板一些简单实用方法
- 第三章 栈和队列 2,判断题
- 使用Shell脚本对Linux系统和进程资源进行监控
- jsp/Servlet
- zoj 2770 Burn the Linked Camp 差分约束
- Java Service Wrapper使用中的问题
- 一款搜索音乐的API
- 编程珠玑(2)第十三章学习笔记
- objective-c 中三种产生随机数的方法
- 浅谈机械磁盘相关概念:磁道、柱面、扇区、寻道时间、旋转延迟、数据传输时间
- 九度OJ 1031 xxx定律
- Android开发中Activity切换导致的onCreate重复执行的问题
- 使用SendMessage模拟某一按钮的点击事件