夏夜、

心若平似镜、何题不AC。

2014年3月29日

UVA 1376 Animal Run 最短路

摘要: 平面图最小割转最短路书上是说以边为结点建图但是我觉得好像以每块空白区域为结点建图会更自然点。把矩形的右上方编号为0,左下方编号为1,分别为起点终点//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef 阅读全文

posted @ 2014-03-29 19:51 BMan、 阅读(692) 评论(0) 推荐(0) 编辑

UVA 1048 Low Cost Air Travel 最短路

摘要: 以(i,j) 为结点建图,其中i表示目前已经到过行程单上的前i个城市,j是目前在哪个城市。注意1.起点是行程单上的第一个城市2.城市的编号会很大,要重新编号。//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;t 阅读全文

posted @ 2014-03-29 19:47 BMan、 阅读(499) 评论(0) 推荐(0) 编辑

UVA 1078 Steam Roller 建图 Dijksta

摘要: 把一个点(r,c)拆成(r,c,dir,doubled)八个点表示上个点是从dir方向到(r,c)的,doubled表示那条边是否已经加倍。而后就是考虑清楚细节,建图。最后跑最短路。//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef lo 阅读全文

posted @ 2014-03-29 19:43 BMan、 阅读(299) 评论(0) 推荐(0) 编辑

UVA 11478 Halum 差分约束系统 + 二分答案

摘要: 设sum(u)为在结点u上的全部操作叠加(操作顺序无影响)则原边w(a,b)变为w(a,b)+sum(a)-sum(b)二分答案x,则w(a,b)+sum(a)-sum(b)>=x,即sum(b)-sum(a)#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair pii 阅读全文

posted @ 2014-03-29 19:38 BMan、 阅读(268) 评论(0) 推荐(0) 编辑

UVA 11090 Going in Cycle!! 二分答案 + bellman-ford

摘要: 求平均值最小的环,如果平均值最小为x,则如果把每条边的权值都减(x+1),那么新图将会有负环,用bellman ford判断。//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef unsigned 阅读全文

posted @ 2014-03-29 19:32 BMan、 阅读(226) 评论(0) 推荐(0) 编辑

UVA 10537 The Toll! Revisited 最短路

摘要: d[u]表示从u离开时最少需要多少才能达到要求。从终点开始往前更新,求出前继结点最少需要的d是多少//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef unsigned long long ull; 阅读全文

posted @ 2014-03-29 19:27 BMan、 阅读(156) 评论(0) 推荐(0) 编辑

UVA 1416 Warfare And Logistics 最短路树

摘要: 对每个点求最短路,同时求出最短路树。枚举每条边,如果这条边在最短路树上,那么删掉这条边就需要重新计算最短路,否则不需要。//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef unsigned lon 阅读全文

posted @ 2014-03-29 19:23 BMan、 阅读(220) 评论(0) 推荐(0) 编辑

UVA 10917 Walk Through the Forest 最短路 + DP

摘要: 求出最短路后,如果d[A]#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair pii;#define pb(a) push(a)#define INF 0x1f1f1f1f#define lson idx T min(const T& a,const T& 阅读全文

posted @ 2014-03-29 19:18 BMan、 阅读(191) 评论(0) 推荐(0) 编辑

UVA 11374 Airport Express 最短路

摘要: 分别求出以S和E为起点的最短路,然后枚举每一张商务票 (u,v)求 A(u) + w(u,v) + B(v)//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef unsigned long long 阅读全文

posted @ 2014-03-29 19:16 BMan、 阅读(243) 评论(0) 推荐(0) 编辑

导航