
数据结构
pullulate_99
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
HDU-1711-KMP模板
推荐!!!https://www.cnblogs.com/zhangtianq/p/5839909.html 在这里保存模板!! #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ...原创 2018-02-13 12:21:16 · 222 阅读 · 0 评论 -
哈理工OJ- 1161 - Leyni【树状数组】
HRBUST - 1161 - Leyni【树状数组】 Leyni被人掳走,身在水深火热之中… 小奈叶为了拯救Leyni,独自一人前往森林深处从静竹手中夺回昏迷中的Leyni。 历经千辛万苦,小奈叶救出了Leyni,但是静竹为此极为恼怒,决定对他们发起最强烈的进攻。 不过小奈叶有一个叫做能量保护圈的道具,可以保护他们。 这个保护圈由n个小的小护盾围成一圈,从1到n编号。当某一块小护盾受...原创 2018-02-21 19:47:34 · 289 阅读 · 0 评论 -
树状数组练习:HDU 1556,POJ 1195,POJ 3321,POJ 2352
HDU 1556 Color the ball /一位树状数组板子题(但c[]已经不是定义上的数组了,但是很常用) #include&lt;bits/stdc++.h&gt; using namespace std; const int maxn=100005; int n; int c[maxn]; int lowbit(int x) { return x&amp;-x; } ...原创 2018-08-01 00:42:25 · 215 阅读 · 0 评论 -
POJ-1182-食物链【带权并查集】
题目链接: http://poj.org/problem?id=1182 题目大意: 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是”1 X Y”,表示X和Y是同类。 ...原创 2018-02-20 16:15:57 · 283 阅读 · 0 评论 -
POJ - 2492 -A Bug's Life 【带权并查集讲解】
POJ - 2492 -A Bug’s Life Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only intera...原创 2018-02-20 14:16:40 · 337 阅读 · 0 评论 -
POJ1-1611-The Suspects【并查集】
POJ1-1611-The Suspects[并查集】 题意:跟0接触的都容易感染,找到多少人可疑。 用并查集基本套#include<stdio.h> #include<iostream> #include<algorithm> using namespace std;int fa[30000], a[30000];int Find(int x) { if(fa[x]!=x)原创 2018-02-05 19:11:29 · 159 阅读 · 0 评论 -
How Many Tables HDU 1213(并查集)
Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends know each other...原创 2018-02-03 00:26:33 · 258 阅读 · 0 评论 -
HDU-1232-畅通工程(并查集)
畅通工程Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input 测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < ...原创 2018-01-19 00:41:47 · 471 阅读 · 0 评论 -
学习: ACM-字符串-字典树模板HDU-1251-统计难题
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstdlib&amp;gt; #include &amp;lt;cstring&amp;gt; const int MAXN = 26; struct Trie { // 代表当前节点可以延伸出的边,数量可变 Trie *Next[MAXN]; // 标记当前节点是否是保转载 2018-08-01 13:54:36 · 271 阅读 · 0 评论 -
POJ2255-Tree Recovery【二叉树遍历】
二叉树遍历 给出前序和中序,求后序 #include &amp;lt;iostream&amp;gt; #include&amp;lt;stdio.h&amp;gt; #include&amp;lt;string.h&amp;gt; using namespace std; char mid[27]; char pre[27]; int n=-1; void maketree(int i,i原创 2018-10-21 22:19:40 · 260 阅读 · 0 评论 -
POJ 3264 线段树
RMQ线段树 区间最大值最小值 #include&lt;cstdio&gt; #include&lt;cstring&gt; #include&lt;algorithm&gt; using namespace std; const int maxn=50050; #define inf 9999999999; struct node { int l,r; int M原创 2018-07-26 22:11:37 · 255 阅读 · 0 评论 -
Curious Robin Hood【线段树单点更新】
Robin Hood likes to loot rich people since he helps the poor people with this money. Instead of keeping all the money together he does another trick. He keeps n sacks where he keeps this money. The sa...原创 2018-04-04 23:11:41 · 344 阅读 · 0 评论 -
HDU-1754-I Hate It【线段树求区间最值】
#include&lt;stdio.h&gt; #include&lt;string.h&gt; #include&lt;algorithm&gt; using namespace std; const int maxn=200005; #define lson l,m,rt; #define LL(x) (x&lt;&lt;1) #define RR(x)原创 2018-03-09 10:57:34 · 299 阅读 · 0 评论 -
【线段树学习】POJ-3468-A Simple Problem with Integers
A Simple Problem with Integers Description You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a g...原创 2018-02-26 00:15:18 · 352 阅读 · 0 评论 -
HDU-1166-敌兵布阵【树状数组讲解笔记】
1、 int Lowbit(x) { return x&amp;amp;amp;(-x); } 如: 【二进制为8位】 x =1: 1 &amp;amp;amp;-1 0000 0001 &amp;amp;amp; 1111 1111 = 1 x = 6: 6 &amp;amp;amp; -6原创 2018-02-14 00:38:01 · 221 阅读 · 0 评论 -
数据结构-KMP【串匹配】
数据结构-KMP 对模式串next数组的理解: 比如我们已经知道ababab,q=4时,next[4]=2(k=2,表示该字符串的前5个字母组成的子串ababa存在相同的最长前缀和最长后缀的长度是3,所以k=2,next[4]=2。这个结果可以理解成我们自己观察算的,也可以理解成程序自己算的,这不是重点,重点是程序根据目前的结果怎么算next[5]的).,那么对于字符串ababab,我们计算nex...原创 2018-09-26 22:51:33 · 482 阅读 · 0 评论 -
哈理工OJ - 1526 - 小猴和冒泡 【归并排序求逆序数】
小猴同学遇见了一道难题:给出一个长度为n的序列,将其变成递增序列。 可能对于你来说并不算难题,因为一个qsort就完全可以解决,但是对于小猴同学来说就是个难题了,因为他只会冒泡。 冒泡的思想相信大家都会,每次比较相邻两个数的大小,如果想要得到递增序列,那么前一个数大于后一个数就要把它们交换一下位置,经过n-1趟扫描就能得到想要的递增序列。 但是冒泡的时间复杂度是O(n^2),经常会超时,我们...原创 2018-02-21 19:45:04 · 301 阅读 · 0 评论