夏夜、

心若平似镜、何题不AC。

03 2014 档案

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、 阅读(708) 评论(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、 阅读(509) 评论(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、 阅读(315) 评论(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、 阅读(278) 评论(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、 阅读(234) 评论(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、 阅读(162) 评论(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、 阅读(229) 评论(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、 阅读(199) 评论(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、 阅读(257) 评论(0) 推荐(0)

UVA 10319 Manhattan 2-sat
摘要:不难想到是2-sat,这题最繁的就是加边的了//#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;typedef pair pii;#define pb 阅读全文

posted @ 2014-03-24 14:21 BMan、 阅读(169) 评论(0) 推荐(0)

UVA 1357 Cells
摘要:考虑一颗普通的树,DFS一遍后得到每个点的DFS前序历遍顺序值dfsid[] ,和以改点为根的子树的总结点数num[]。(比如第一组样例dfsid[]={0,1,6,8,2,3,7,9,4,5} num[]={10,5,2,2,1,3,1,1,1,1});那么要判断a是否为b的祖先,只要满足dfsid[a]#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;t 阅读全文

posted @ 2014-03-23 23:12 BMan、 阅读(283) 评论(0) 推荐(0)

UVA 610 Street Directions 双连通分量
摘要:首先找到全部双连通分量,然后对于某一个结点数大于2的连通分量,可以把全部的边改成单向的,按DFS的顺序。结点数为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;typed 阅读全文

posted @ 2014-03-23 18:02 BMan、 阅读(185) 评论(0) 推荐(0)

UVA 11504 Dominos 强连通分量
摘要:找出强连通分量,缩点后统计入度为0的结点数。//#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;typedef pair pii;#define pb 阅读全文

posted @ 2014-03-23 17:48 BMan、 阅读(187) 评论(0) 推荐(0)

UVA 11080 Place the Guards 二分图判定
摘要:每个连通块分别取min{白色,黑色}//#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;typedef pair pii;#define pb(a) 阅读全文

posted @ 2014-03-23 17:46 BMan、 阅读(180) 评论(0) 推荐(0)

UVA 11294 Wedding 2sat
摘要:训练指南上的翻译错了,只有一对新娘新郎,其他是夫妻。//#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;typedef pair pii;#defin 阅读全文

posted @ 2014-03-23 17:44 BMan、 阅读(158) 评论(0) 推荐(0)

UVA 10765 Doves and bombs 双连通分量
摘要://#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;typedef pair pii;#define pb(a) push(a)#define INF 阅读全文

posted @ 2014-03-23 17:42 BMan、 阅读(121) 评论(0) 推荐(0)

UVA 11396 Claw Decomposition 二分图判定
摘要://#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;typedef pair pii;#define pb(a) push(a)#define INF 阅读全文

posted @ 2014-03-23 17:39 BMan、 阅读(178) 评论(0) 推荐(0)

UVA 1391 Astronauts 2-sat
摘要://#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;typedef pair pii;#define pb(a) push(a)#define INF 阅读全文

posted @ 2014-03-19 23:21 BMan、 阅读(188) 评论(0) 推荐(0)

UVA 1146 Now or later 2-sat
摘要://#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;typedef pair pii;#define pb(a) push(a)#define INF 阅读全文

posted @ 2014-03-19 23:20 BMan、 阅读(180) 评论(0) 推荐(0)

UVA 11324 The Largest Clique 强连通分量 DP
摘要:找强连通分量,缩点,DP//#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;typedef pair pii;#define pb(a) push(a 阅读全文

posted @ 2014-03-19 23:19 BMan、 阅读(183) 评论(0) 推荐(0)

UVA 12167 Proving Equivalences 强连通分量
摘要://#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;typedef pair pii;#define pb(a) push(a)#define INF 阅读全文

posted @ 2014-03-19 23:17 BMan、 阅读(207) 评论(0) 推荐(0)

UVA 1108 Mining Your Own Business 双连通分量 割点
摘要:双连通分量://#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;typedef pair pii;#define pb(a) push(a)#defi 阅读全文

posted @ 2014-03-19 23:15 BMan、 阅读(308) 评论(0) 推荐(0)

UVA 1364 Knights of the Round Table 双连通分量+二分图判定
摘要://#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;typedef pair pii;#define pb(a) push(a)#define INF 阅读全文

posted @ 2014-03-19 23:13 BMan、 阅读(279) 评论(0) 推荐(0)

POJ 2441 Arrange the Bulls 状态DP
摘要://#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;typedef pair pii;#define pb(a) push(a)#define INF 阅读全文

posted @ 2014-03-18 18:34 BMan、 阅读(131) 评论(0) 推荐(0)

POJ 1769 Minimizing maximizer 线段树优化DP
摘要:题意抽象出数学模型就是说“最少需要多少个区间能完全覆盖整个区间[1,n]”。一开始没看到“subsequence of the given sequence” ,直接排序,然后二分查找,居然1A。。充满了奇迹。AC后百度题解发现自己看错题也能AC,相当自豪!dp[i]表示覆盖[1,i]最少需要的区间数。那么对于某段区间[a,b],dp[b]=min(dp[a....b-1])+1;更新只需更新一点,不用一段。还有几个细节//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#incl 阅读全文

posted @ 2014-03-12 17:13 BMan、 阅读(806) 评论(0) 推荐(0)

POJ 2686 Traveling by Stagecoach 状态DP
摘要://#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;typedef pair pii;#define pb(a) push(a)#define INF 阅读全文

posted @ 2014-03-11 22:36 BMan、 阅读(184) 评论(0) 推荐(0)

导航