
-> 数据结构 <-
文章平均质量分 75
Joefery
生命不息,战斗不止。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ 3468 线段树 区间增减 区间求和
题目链接 #include #include #include #include #include using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 const int maxn = 150000; struct Node{ long long sum,add; }st[maxn<原创 2016-07-12 21:49:58 · 539 阅读 · 0 评论 -
UVA 12657 链表模拟
You have n boxes in a line on the table numbered 1. . . n from left to right. Your task is to simulate 4 kinds of commands: • 1 X Y : move box X to the left to Y (ignore this if X is already the lef原创 2016-05-30 18:07:06 · 486 阅读 · 0 评论 -
hdu 1213 How Many Tables【并查集】
How Many Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 21257 Accepted Submission(s): 10532 Problem Description Today is原创 2016-03-03 21:03:35 · 349 阅读 · 0 评论 -
hdu 1272 小希的迷宫【并查集】
小希的迷宫 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 39256 Accepted Submission(s): 12049 Problem Description 上次Gardon的迷宫城堡小希玩了很原创 2016-03-03 21:10:54 · 418 阅读 · 0 评论 -
CSU 1809 Parenthesis 【前缀和+RMQ】
Description Bobo has a balanced parenthesis sequence P=p 1 p 2…p n of length n and q questions. The i-th question is whether P remains balanced after p ai and p bi swapped. Note that questions原创 2016-09-05 00:25:11 · 757 阅读 · 0 评论 -
RMQ模版
/* 类型:RMQ模板 分析:用于求取区间最小值和最大值,修改值比较麻烦, O(nlogn)时间内进行预处理,O(1)时间内回答每个查询. */ #include #include #include #include #include using namespace std; typedef long long ll; int a[100005]; int Mi原创 2016-09-05 00:44:16 · 452 阅读 · 0 评论 -
ural 1987. Nested Segments【离散化+贪心+线段树】
1987. Nested Segments Time limit: 1.0 second Memory limit: 64 MB You are given n segments on a straight line. For each pair of segments it is known that they either have no common points or原创 2016-09-07 21:28:15 · 573 阅读 · 0 评论 -
UVALive - 3135 Argus【优先队列】
题目链接 题意:有一系列的事件,它每Period秒钟就会产生编号为qNum的事件,你的任务是模拟出前k个事件,如果多个事件同时发生,先处理qNum小的事件 用优先队列解决多路并归的基础题,把k个有序表合成一个有序表。 #include #include #include #include #include #include #include using namespac原创 2016-06-01 21:09:57 · 492 阅读 · 0 评论 -
HDU 1251 统计难题 【字典树】
Description Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). Input 输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连原创 2016-10-17 02:20:48 · 461 阅读 · 0 评论 -
HDU 1671 Phone List 【字典树】
Description Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers: 1. Emergency 911原创 2016-10-17 21:52:49 · 397 阅读 · 0 评论 -
CSU 1216 异或最大值【字典树】
Description 给定一些数,求这些数中两个数的异或值最大的那个值 Input 第一行为数字个数n,1 Output 任意两数最大异或值 Sample Input 3 3 7 9 Sample Output 14 /*原创 2016-10-19 00:57:52 · 674 阅读 · 0 评论 -
Codeforces 217A. Ice Skating 【并查集】
A. Ice Skating time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bajtek is learning to skate on ice. He's a b原创 2016-08-30 22:08:37 · 672 阅读 · 0 评论 -
UVALive 6910 Cutting Tree【并查集】
题目链接 /* 题意:给你含有n个节点的森林,和q次操作,每次操作包含两种情况 1. C a 表示删除a和父亲节点的连边 2. Q a b 表示询问a,b节点是否属于同一个同一棵树中 类型:并查集 分析:要做到删边之后仍然可以找到每棵树的根,那么在合并两个点的时候只 保存父亲节点是谁就行了,然后查找的原创 2016-10-20 22:27:56 · 350 阅读 · 0 评论 -
HDU 1166 一维树状数组
题目链接 单点修改,区间查询和。 #include #include #include #include #include #include #include using namespace std; int v[50005],n; int Lowbit(int x){ return x&(-x); } void Add(int pos,int val){ while(pos<原创 2016-07-11 14:55:50 · 410 阅读 · 0 评论 -
POJ 2352 Star 树状数组
题目链接 在坐标上有n个星星,如果某个星星坐标为(x, y), 它的左下位置为:(x0,y0),x0 按照y递增,如果y相同则x递增的顺序给出n个星星,求出所有level水平的数量。 题目中输入是按照y递增,如果y相同则x递增的顺序给出的, 所以,对于第i颗星星,它的level就是之前出现过的星星中,横坐标x小于等于i星横坐标的那些星星的总数量(前面的y一定比原创 2016-07-11 15:46:16 · 485 阅读 · 0 评论 -
POJ 3264 Balanced Lineup 线段树基础
题目链接 N个数,Q次询问,每次询问区间中的最大值和最小值的差。 #include #include #include #include #include #include #include using namespace std; #define Maxn 200005 #define INF 10000000 struct Node{ int l,r; //区间的左右原创 2016-07-11 21:13:05 · 398 阅读 · 0 评论 -
线段树 单点增减,单点替换,区间最值,区间求和(模板)
#include #include #include #include #include #include using namespace std; #define INF 10000000 #define lson l,mid,rt<<1 //左儿子 #define rson mid+1,r,rt<<1|1 //右儿子 const int maxn = 222222; struct原创 2016-07-12 20:11:19 · 640 阅读 · 0 评论 -
HYSBZ 1588 营业额统计【伸展树】
Description 营业额统计 Tiger最近被公司升任为营业部经理,他上任后接受公司交给的第一项任务便是统计并分析公司成立以来的营业情况。 Tiger拿出了公司的账本,账本上记录了公司成立以来每天的营业额。分析营业情况是一项相当复杂的工作。由于节假日,大减价或者是其他情况的时候,营业额会出现一定的波动,当然一定的波动是能够接受的,但是在某些时候营业额突变得很高或是很低,这就证明公司此时原创 2016-11-08 23:03:51 · 675 阅读 · 0 评论