夏夜、

心若平似镜、何题不AC。

2014年4月5日

POJ 1979 Red and Black DFS

摘要: 简单DFS。//#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-04-05 23:32 BMan、 阅读(140) 评论(0) 推荐(0) 编辑

POJ 3169 Layout 差分约束系统

摘要: //#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-04-05 22:55 BMan、 阅读(132) 评论(0) 推荐(0) 编辑

POJ 3723 Conscription 最小生成树

摘要: 想清楚后能发现就要让我们求最小生成树(如果图连通的话,否则就是森林)//#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 pi 阅读全文

posted @ 2014-04-05 21:28 BMan、 阅读(158) 评论(0) 推荐(0) 编辑

POJ 3255 Roadblocks 次短路

摘要: 和Dijksta求最短路一样,只是要维护两个数组:最短路d1,次短路d2。然后更新的时候注意细节。//#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-04-05 20:45 BMan、 阅读(157) 评论(0) 推荐(0) 编辑

UVA 11367 Full Tank? 最短路

摘要: 以状态(u,fuel)为结点建图(把每个点拆成100个),表示在点u时还剩下fuel个单位的燃料,那么状态就可以这样转移:(u,fuel)->(u,fuel+i) : 加i单位的燃料,所以这条边的权值就是 i*p[u];(u,fuel) ->(v,fuel-dist): 走到另一个点,其中dist为路径。当然直接这样做可能会超时,需要做两个小优化(做其中一个就能AC了)1. (u,fuel)->(u,fuel+i) 中的i只需为1就行了,这样就能边数从100^2降到100. 比如(u,fuel)->(u,fuel+3)可以用 (u,fuel)->(u,fuel+1 阅读全文

posted @ 2014-04-05 19:31 BMan、 阅读(200) 评论(0) 推荐(0) 编辑

UVA 10269 Adventure of Super Mario 最短路

摘要: (i,j)表示当前在结点j,还剩下i次使用魔法的机会。以(i,j)为结点建图,求最短路。//#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;typed 阅读全文

posted @ 2014-04-05 13:30 BMan、 阅读(140) 评论(0) 推荐(0) 编辑

UVA 10603 Fill 最短路

摘要: //#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-04-05 13:28 BMan、 阅读(153) 评论(0) 推荐(0) 编辑

导航