上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 16 下一页
摘要: 本来是一道普通的差分约束题,结果特么的写完连样例都过不了。。。后来才在差分约束的百度百科中现这段话:1.如果将源点到各点的距离初始化为0,最终求出的最短路满足 它们之间相互最接近了;2.如果将源点到各点的距离初始化为INF(无穷大),其中之1为0,最终求出的最短路满足 它们与该点之间相互差值最大。呵... 阅读全文
posted @ 2015-03-12 17:58 NanoApe 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 先处理成前缀和关系,然后可以很明显得看得出这是一个差分约束。那么就是最短路问题了。顺便复习了一下SPFA加SLF优化是怎么写的,也学习到了另一个STL——Deque双向队列。#include #include #include #include #include #include #include ... 阅读全文
posted @ 2015-03-11 18:53 NanoApe 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 无修改的查询题,分块莫队+树状数组搞之。可这样貌似会Tle……于是不用树状数组,改成对权值进行分块,使查询的复杂度变成O(n^0.5),修改则是O(1)。(原树状数组的复杂度:查询O(lgn),修改O(lgn))#include #include #include #include #include... 阅读全文
posted @ 2015-03-10 21:20 NanoApe 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 用分块莫队离线询问的同时用树状数组快速计算逆序对个数。#include #include #include #include #include #include #include #include #define rep(i, l, r) for(int i = l; i = r; i--)#def... 阅读全文
posted @ 2015-03-10 20:09 NanoApe 阅读(214) 评论(0) 推荐(0) 编辑
摘要: BZOJ2038的弱化版。。。同样分块莫队。#include #include #include #include #include #include #include #include #define rep(i, l, r) for(int i = l; i = r; i--)#define N... 阅读全文
posted @ 2015-03-09 21:36 NanoApe 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 离线做法:莫队。离线处理询问,对左端点进行分块,在同一块内的右端点则从小到大排序。接着对于上一个询问[l,r]和当今询问[l',r']不断调整区间范围。怎么调整呢?对于[l,r]所含的信息,我们可以花O(1)的时间调整成[l,r+1],[l,r-1],[l+1,r],[l-1,r]。最正宗的莫队貌似... 阅读全文
posted @ 2015-03-09 21:34 NanoApe 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 估价函数其实就是与目标状态有几个不同。。。迭代启发搜索。#include #include #include #include #include #include #include #include #define rep(i, l, r) for(int i = l; i = r; i--)#de... 阅读全文
posted @ 2015-03-05 21:54 NanoApe 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 为每个状态定义两个函数S和H,分别表示当前状态到列一致和行一致的目标状态的最少操作次数。然后有了估价函数F=Min(S,H)就可以IDA*了。#include #include #include #include #include #include #include #include #define... 阅读全文
posted @ 2015-03-05 21:01 NanoApe 阅读(175) 评论(0) 推荐(0) 编辑
摘要: BFS+预处理。一组解的话Usaco有题。。。要是T组解的话就预处理一下。#include #include #include #include #include #include #include #include #define rep(i, l, r) for(int i=l; i=r; i-... 阅读全文
posted @ 2015-03-04 22:15 NanoApe 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 深搜+几个剪枝。貌似搜索顺序也挺重要的。。。我不知是不是因为这个然后Tle了好久。。。#include #include #include #include #include #include #include #include #define rep(i, l, r) for(int i=l; i... 阅读全文
posted @ 2015-03-04 18:37 NanoApe 阅读(162) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 16 下一页
AmazingCounters.com