
-> 数据结构 <-
文章平均质量分 75
Joefery
生命不息,战斗不止。
展开
-
POJ 3468 线段树 区间增减 区间求和
题目链接#include#include#include#include#includeusing namespace std;#define lson l,mid,rt<<1#define rson mid+1,r,rt<<1|1const int maxn = 150000;struct Node{ long long sum,add;}st[maxn<原创 2016-07-12 21:49:58 · 523 阅读 · 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 4kinds 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 · 470 阅读 · 0 评论 -
hdu 1213 How Many Tables【并查集】
How Many TablesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 21257 Accepted Submission(s): 10532Problem DescriptionToday is原创 2016-03-03 21:03:35 · 342 阅读 · 0 评论 -
hdu 1272 小希的迷宫【并查集】
小希的迷宫Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 39256 Accepted Submission(s): 12049Problem Description上次Gardon的迷宫城堡小希玩了很原创 2016-03-03 21:10:54 · 400 阅读 · 0 评论 -
CSU 1809 Parenthesis 【前缀和+RMQ】
DescriptionBobo 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 · 735 阅读 · 0 评论 -
RMQ模版
/* 类型:RMQ模板 分析:用于求取区间最小值和最大值,修改值比较麻烦, O(nlogn)时间内进行预处理,O(1)时间内回答每个查询.*/#include#include#include#include#includeusing namespace std;typedef long long ll;int a[100005];int Mi原创 2016-09-05 00:44:16 · 439 阅读 · 0 评论 -
ural 1987. Nested Segments【离散化+贪心+线段树】
1987. Nested SegmentsTime limit: 1.0 secondMemory limit: 64 MBYou 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 · 560 阅读 · 0 评论 -
UVALive - 3135 Argus【优先队列】
题目链接题意:有一系列的事件,它每Period秒钟就会产生编号为qNum的事件,你的任务是模拟出前k个事件,如果多个事件同时发生,先处理qNum小的事件用优先队列解决多路并归的基础题,把k个有序表合成一个有序表。#include#include#include#include#include#include#includeusing namespac原创 2016-06-01 21:09:57 · 483 阅读 · 0 评论 -
HDU 1251 统计难题 【字典树】
DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连原创 2016-10-17 02:20:48 · 451 阅读 · 0 评论 -
HDU 1671 Phone List 【字典树】
DescriptionGiven 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 · 390 阅读 · 0 评论 -
CSU 1216 异或最大值【字典树】
Description给定一些数,求这些数中两个数的异或值最大的那个值Input第一行为数字个数n,1 Output任意两数最大异或值Sample Input3379Sample Output14/*原创 2016-10-19 00:57:52 · 650 阅读 · 0 评论 -
Codeforces 217A. Ice Skating 【并查集】
A. Ice Skatingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBajtek is learning to skate on ice. He's a b原创 2016-08-30 22:08:37 · 662 阅读 · 0 评论 -
UVALive 6910 Cutting Tree【并查集】
题目链接/* 题意:给你含有n个节点的森林,和q次操作,每次操作包含两种情况 1. C a 表示删除a和父亲节点的连边 2. Q a b 表示询问a,b节点是否属于同一个同一棵树中 类型:并查集 分析:要做到删边之后仍然可以找到每棵树的根,那么在合并两个点的时候只 保存父亲节点是谁就行了,然后查找的原创 2016-10-20 22:27:56 · 338 阅读 · 0 评论 -
HDU 1166 一维树状数组
题目链接单点修改,区间查询和。#include#include#include#include#include#include#includeusing 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 · 399 阅读 · 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 · 461 阅读 · 0 评论 -
POJ 3264 Balanced Lineup 线段树基础
题目链接N个数,Q次询问,每次询问区间中的最大值和最小值的差。#include#include#include#include#include#include#includeusing namespace std;#define Maxn 200005#define INF 10000000struct Node{ int l,r; //区间的左右原创 2016-07-11 21:13:05 · 383 阅读 · 0 评论 -
线段树 单点增减,单点替换,区间最值,区间求和(模板)
#include#include#include#include#include#includeusing 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 · 627 阅读 · 0 评论 -
HYSBZ 1588 营业额统计【伸展树】
Description营业额统计 Tiger最近被公司升任为营业部经理,他上任后接受公司交给的第一项任务便是统计并分析公司成立以来的营业情况。 Tiger拿出了公司的账本,账本上记录了公司成立以来每天的营业额。分析营业情况是一项相当复杂的工作。由于节假日,大减价或者是其他情况的时候,营业额会出现一定的波动,当然一定的波动是能够接受的,但是在某些时候营业额突变得很高或是很低,这就证明公司此时原创 2016-11-08 23:03:51 · 662 阅读 · 0 评论