摘要:
思路:并查集,在查找,路径压缩的时候,用num[i]记录i被移动的次数,有:sum[i] += sum[father[i]]。#include#include#includeusing namespace std;int father[10005], num[10005], city[10005];... 阅读全文
posted @ 2014-04-30 18:37
wangzhili
阅读(89)
评论(0)
推荐(0)
摘要:
思路:lazy标记,每次只记录最后那个数的增量,需要是再向前传递。#include#include#includeusing namespace std;long long int Delta[200005], a[200005];double sum;int main(int argc, char... 阅读全文
posted @ 2014-04-30 18:37
wangzhili
阅读(94)
评论(0)
推荐(0)
摘要:
思路:并查集应用,处理是倒过来处理。#include#include#includeusing namespace std; int father[10005], a[100005], b[100005], block[100005]; int find(int x){ return x ==... 阅读全文
posted @ 2014-04-30 18:37
wangzhili
阅读(78)
评论(0)
推荐(0)
摘要:
思路:据说是单调队列,我用线段树过的。。。#include#include#define MAX 1000005using namespace std;typedef struct{ int left, right, mid, min, max;}NodeTree;NodeTree node[... 阅读全文
posted @ 2014-04-30 18:37
wangzhili
阅读(82)
评论(0)
推荐(0)
摘要:
#include#include#includeusing namespace std;struct cmp{ bool operator()(int x, int y) { return x > y; }};priority_queue, cmp>q;int mai... 阅读全文
posted @ 2014-04-30 18:37
wangzhili
阅读(96)
评论(0)
推荐(0)
摘要:
#include#include#includeusing namespace std; #define N 200005 long long int ans, cow[N], lose[N]; int main(int argc, char const *argv[]) { int n; ... 阅读全文
posted @ 2014-04-30 18:37
wangzhili
阅读(85)
评论(0)
推荐(0)
摘要:
思路:最大流算法,基于FF方法:1.Dinic:/************************************************************************* > File Name: Dith.cpp > Author: ... 阅读全文
posted @ 2014-04-30 18:37
wangzhili
阅读(76)
评论(0)
推荐(0)
摘要:
#include#include#include#includeusing namespace std;int res[20][20], vis[20], pre[20];queueq;int N, M;bool bds(int s, int t){ memset(vis, 0, sizeof... 阅读全文
posted @ 2014-04-30 18:37
wangzhili
阅读(139)
评论(0)
推荐(0)
摘要:
这个算法是基于FF方法,就是通过不断求残余网络的增广路来增广流量,直到找不到增广路为止。注意:每次找到增广路以后都要更新原网络。EK算法通过BFS寻找源S到汇T的一条最短路径,因此时间复杂度是O(VE^2).模板代码如下:#include#include#include#include#define... 阅读全文
posted @ 2014-04-30 18:37
wangzhili
阅读(201)
评论(0)
推荐(0)
摘要:
思路:使用优先队列,每次都取出先前状态中距离最短的状态,注意,入队的不是点也不是边,而是先前满足花费小于K的所有的可行状态,队列里面保存的是先前取的点的状态,这样每次弹出距离最小的状态进行更新,到最后得到的一定是满足距离最小且花费不大于K的解,一旦发现N点在状态中,就可以返回了,因为此时的状态就是最... 阅读全文
posted @ 2014-04-30 18:37
wangzhili
阅读(254)
评论(0)
推荐(0)
浙公网安备 33010602011771号