摘要: 线段树,懒惰标记 1 #include 2 #include 3 using namespace std; 4 #define N 400010 5 int sum[N],lazy[N]; 6 void pushup(int root){ 7 sum[root]=sum[root*2]+... 阅读全文
posted @ 2014-07-31 13:26 Mr.XuJH 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 第一题线段树,纪念一下 1 #include 2 #include 3 using namespace std; 4 int tree[800005]; 5 void build(int l,int r,int root){ 6 if(l==r){ 7 scanf("%... 阅读全文
posted @ 2014-07-31 10:01 Mr.XuJH 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 我们用dis[i]表示目前i距离源点的最短距离mo[i]表示在d[i]最优的前提下所花掉的钱#include #include #include #include using namespace std;#define INF 1 rhs.suml; } void init(int l,... 阅读全文
posted @ 2014-07-30 11:37 Mr.XuJH 阅读(156) 评论(0) 推荐(0) 编辑
摘要: d[i]表示在[0,i]这个区间内一共选了d[i]个数对于每个为[ai,bi]的区间,你必须在这个区间上至少取ci个不同的整数,用d[i]如何表示?d[ bi ]-d[ ai-1 ] >= ciEdge:(ai-1 -> bi) val = ci另外:0#include #include #incl... 阅读全文
posted @ 2014-07-30 09:53 Mr.XuJH 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 解法:对u->v的边 add_edge(u,v,0)增加一条u->v反向边 add_edge(v,u,1)求一遍1->n的最短路#include #include #include using namespace std;#define M 20010 //用了几次 10010 R... 阅读全文
posted @ 2014-07-29 14:21 Mr.XuJH 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 高仿代码:#include #include #include #include #include #include using namespace std;#define N 205#define M 2005const int inf = 0x3f3f3f3f;int v[M],w[M],nex... 阅读全文
posted @ 2014-07-29 09:57 Mr.XuJH 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 高仿代码:#include #include #include #include #include #include using namespace std;#define N 205#define M 2005const int inf = 0x3f3f3f3f;int v[M],u[M],d[N... 阅读全文
posted @ 2014-07-29 09:17 Mr.XuJH 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 畅通工程续高仿代码如下#include #include #include #include using namespace std;const int inf = 0x3f3f3f3f;#define N 205int d[N][N];void floyd(int n){ for(int k = ... 阅读全文
posted @ 2014-07-28 22:45 Mr.XuJH 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 畅通工程续第一次写dijkstra算法高仿代码如下:#include #include #include #include #include #include using namespace std;#define N 205#define M 2005typedef pair pii;int v[... 阅读全文
posted @ 2014-07-28 17:09 Mr.XuJH 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 第一道Kruskal算法题#include #include #include using namespace std;#define max 505int f[max],maxw;struct edge{ int st,en,w;}ed[max*max/2];int find(int k){ if... 阅读全文
posted @ 2014-07-28 14:07 Mr.XuJH 阅读(125) 评论(0) 推荐(0) 编辑