夏夜、

心若平似镜、何题不AC。

上一页 1 2 3 4 5 6 7 8 ··· 15 下一页

2014年4月5日

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) 编辑

2014年4月4日

POJ 2431 Expedition 优先队列

摘要: 由于油箱是无限的,所以每次经过加油站都不选择加油,等到后面油不够了,再来“反悔”,把前面经过的油站的油加上,尽可能选量大的,用优先队列维护。//#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 un 阅读全文

posted @ 2014-04-04 17:01 BMan、 阅读(150) 评论(0) 推荐(0) 编辑

POJ 3253 Fence Repair 贪心

摘要: 每次合并选最短的两块木板,用优先队列优化。//#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-04-04 16:02 BMan、 阅读(133) 评论(0) 推荐(0) 编辑

POJ 3609 Saruman's Army 贪心

摘要: 从坐开始,贪心选择每个点标记还是不标记。//#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-04-04 15:50 BMan、 阅读(268) 评论(0) 推荐(0) 编辑

POJ 3617 Best Cow Line 贪心

摘要: 不能单纯比较头尾两个字符,应该比较头尾两个字符串。//#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 阅读全文

posted @ 2014-04-04 15:33 BMan、 阅读(139) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 ··· 15 下一页

导航