![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
文章平均质量分 52
hhy518518
这个作者很懒,什么都没留下…
展开
-
POJ1988基本的并查集
#include #include using namespace std;static const int MAX = 31000;static int par[MAX];static int sum[MAX];//砖块i所在堆的砖块数目static int under[MAX];//表示i下面有多少个砖块static int GetParent(int a){ if原创 2015-07-25 17:53:47 · 390 阅读 · 0 评论 -
POJ1068双端队列模拟
//题意:P代表当前右括号位置前面有多少个左括号//W代表右括号位置从与它匹配的位置到该位置有多少个右括号#include #include #include #include using namespace std;int n;int P[25];int W[25];int main(){ int T; scanf("%d",&T); while(T--) {原创 2015-10-25 21:54:54 · 364 阅读 · 0 评论 -
UVA11992二维线段树区间修改
#include #include #include #include #include using namespace std;#define MAXN 100006#define inf 0x3f3f3f3fstruct CNode{ int L,R; long long nsum; int nmax; int nmin; long long Inc;//增原创 2015-11-04 23:28:48 · 418 阅读 · 1 评论 -
Hoj1161树状数组统计
可以根据是否被攻击过设置当前结点一直到下一次可用的时候的时间 #include #include #include using namespace std;#define SIZE 100050static int C[SIZE];static int n,q,t;static int bAttack[SIZE];//可攻击时间static int lowbit(int原创 2015-09-15 21:56:48 · 389 阅读 · 0 评论 -
poj3274数位HASH
//题意:求解最大的连续区间使得该区间中每种特征出现的次数是相等的//可以用树状数组类似方法求解sum[i][]表示0-i所有属性出现的次数//那么就是求sum[j][] - sum[i][]最大的j-i的值//sum[j][k]-sum[i][k] = sum[j][0]- sum[i][0] sum[j][k] - sum[j][0] = sun[i][k] - sum[i][0]原创 2015-09-11 20:53:56 · 325 阅读 · 0 评论 -
poj2421kruskal算法模板题
#include #include using namespace std;#define MAX_N 110 #define MAX_E 11000static int N;static struct Edge{ int from; int to; int cost;}edge[MAX_E];static int E;static int cmp(Edge&原创 2015-08-05 22:20:50 · 539 阅读 · 0 评论 -
HDOJ1272并查集加判断森林
#pragma comment(linker, "/STACK:1024000000,1024000000")#include using namespace std;#define MAX_N 100005static int par[MAX_N];static void init(){ for(int i=0;i<MAX_N;++i) par[i] = 0;}st原创 2015-08-05 21:48:20 · 312 阅读 · 0 评论 -
POJ2352树状数组入门统计前面有多少个数与求逆序数对类似
//统计左侧的星星数目就是树状数组模型//因为已经按照y坐标排序了//统计前面有多少个数的问题#include#include#include#includeusing namespace std;static const int size = 32010;static const int N = 15010;static int x;static int c[size];原创 2015-07-23 20:59:33 · 389 阅读 · 0 评论 -
POJ1195二维线段树或者二维树状数组
注意下标是从0开始的但是我们区间是从1开始的所以查询的时候或者增加的时候x+1,y+1二维线段树://二维线段树是一棵4叉树。如果一个节点代表的区间是矩阵[x1,y1] –[x2,y2],那么它的四个子节点代表的区间分别为// [x1,y1] –[(x1+x2)/2, (y1+y2)/2][x1,(y1+y2)/2+1] –[(x1+x2)/2,y2]//[ (x1+x2)/2+1原创 2015-07-26 17:02:20 · 461 阅读 · 1 评论 -
leetcode42 Trapping Rain Water
通过双指针,头指针是当前第一个非递减的位置,尾指针是当前高度位置通过两个栈来维护数据..出栈的时候填充了水以后修改高度重新加入栈内算法思路:1若为空栈直接加入栈 2.若当前不为空栈讨论当前高度与栈顶高度的值 若小于等于栈顶高度直接加入栈 否则设当前位置为j,找到栈内从右到左第一个非递减的位置i将 i原创 2016-11-28 16:36:01 · 247 阅读 · 0 评论