
ACM-数据结构
文章平均质量分 77
hahahahhahello
这个作者很懒,什么都没留下…
展开
-
判断合法出栈序列
PIPI现有a-z 26个小球模拟出入栈操作,小球按照a~z的顺序压入栈,在栈顶的元素可以随时被取出,在游戏开始前给出任意26个字母的一些排列,问是否能够由出栈顺序得到这个排列。输入输入包含多组测试用例。每组测试用例包含26个字母组成的一个序列。输出若出栈顺序合法,输出"yes",否则输出"no".样例输入abcdefghijklmnopqrstuvwxyzza...原创 2019-06-25 19:44:32 · 2051 阅读 · 0 评论 -
CodeForces - 19D Points (线段树+set)
题目链接:http://codeforces.com/problemset/problem/19/D离线,首先要离散化,对x坐标建立线段树,维护区间内y坐标的最大值,每一个x坐标建立一个set#include <bits/stdc++.h>#define lson num << 1#define rson num << 1 | 1using na...原创 2018-08-28 11:19:23 · 273 阅读 · 0 评论 -
HDU5493 Queue(线段树)
QueueTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1481 Accepted Submission(s): 762Problem DescriptionN people numbered from 1 to N ...原创 2018-08-27 21:39:06 · 193 阅读 · 0 评论 -
HDU - 3397 Sequence operation && HDU - 3911 Black And White(线段树)
两道线段树的硬怼题,都是线段树的基本操作,区间合并,区间求和,区间修改,lazy标记3911#include <bits/stdc++.h>using namespace std;const int MAXN = 100005;#define lson num << 1#define rson num << 1 | 1struct node...原创 2018-08-26 21:03:19 · 198 阅读 · 0 评论 -
杭电多校第八场 Taotao Picks Apples(线段树)
Taotao Picks ApplesTime Limit: 2000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1862 Accepted Submission(s): 580 Problem DescriptionThere is an ...原创 2018-08-17 21:21:09 · 594 阅读 · 0 评论 -
UVALive - 4108 SKYLINE(线段树区间覆盖+剪枝)
题目链接:https://vjudge.net/problem/UVALive-4108思路:线段树维护区间最大值,最小值,新加入的墙的高度如果小于区间最小值,不做处理,比最大值大,覆盖掉之前的最大值最小值,添加lazy标记,因为维护的是坐标轴上的点,建树的停止条件l+1==r#include <bits/stdc++.h>#define lson num <<...原创 2018-08-12 22:37:45 · 255 阅读 · 0 评论 -
UVA - 12299 RMQ with Shifts (线段树)
题目链接:https://vjudge.net/problem/UVA-12299思路:裸的线段树,因为移动时最多不超过30个数,直接单点更新就行了,然后区间查询,因为答案之间要有空行wa了好几发#include <bits/stdc++.h>#define lson num << 1#define rson num << 1 | 1#defin...原创 2018-08-12 21:45:20 · 258 阅读 · 0 评论 -
UVA - 11525 Permutation (线段树)
题目连接:https://vjudge.net/problem/UVA-11525思路:前几天刚做了一道题是给出一个排列,输出这个排列是按照字典序从小到大的第几个,答案是 s1 * (n - 1)! + s2 * (n - 2)! + ......sn * 0!si表示排列...原创 2018-08-12 21:40:34 · 155 阅读 · 0 评论 -
UVALive - 4730 Kingdom(并查集+线段树)
题目连接:https://vjudge.net/problem/UVALive-4730 思路:用并查集来维护每一个州的城市数目,最上面城市的y坐标maxy,最下面城市的y坐标miny,当在城市之间连接一条路时,如果这两个城市已经在同一个州内,就不用处理了,如果不在同一个州内,首先要现在线段树中删除这两个州的信息,注意如果这个州只有一个城市不用删除,因为线段树内并没有记录只有一个城市的州的...原创 2018-08-12 21:28:34 · 302 阅读 · 0 评论 -
杭电多校第五场 Glad You Came(线段树+剪枝)
Glad You CameTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1405 Accepted Submission(s): 574 Problem DescriptionSteve has an inte...原创 2018-08-07 14:08:54 · 431 阅读 · 0 评论 -
The North American Invitational Programming Contest 2018 E. Prefix Free Code(字典树+树状数组)
Consider nn initial strings of lower case letters, where no initial string is a prefix of any other initial string. Now, consider choosing kk of the strings (no string more than once), and concatenati...原创 2018-08-11 00:01:01 · 713 阅读 · 0 评论 -
HDU 3487 Play with Chain(伸展树)
Play with ChainTime Limit: 6000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7719 Accepted Submission(s): 3030 Problem DescriptionYaoYao is fond of...原创 2018-08-04 10:46:24 · 174 阅读 · 0 评论 -
杭电多校第三场 Problem A. Ascending Rating(单调队列)
Problem A. Ascending RatingTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1374 Accepted Submission(s): 380 Problem DescriptionBef...原创 2018-07-30 21:57:29 · 240 阅读 · 0 评论 -
HDU 6194 string string string (后缀数组)
string string stringTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2377 Accepted Submission(s): 748 Problem DescriptionUncle Mao is ...原创 2018-07-22 20:21:00 · 181 阅读 · 0 评论 -
杭电多校第四场 Problem B. Harvest of Apples(莫队)
Problem B. Harvest of ApplesTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2601 Accepted Submission(s): 1002 Problem DescriptionTh...原创 2018-08-03 19:37:14 · 378 阅读 · 0 评论 -
HDU 1890 Robotic Sort(伸展树)
Robotic SortTime Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5269 Accepted Submission(s): 2340 Problem DescriptionSomewhere deep in th...原创 2018-08-03 19:27:12 · 232 阅读 · 0 评论 -
HDU 6135 A Secret(扩展KMP)
A SecretTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 256000/256000 K (Java/Others)Total Submission(s): 3911 Accepted Submission(s): 1352 Problem DescriptionToday is the birthday ...原创 2018-08-24 20:17:50 · 194 阅读 · 0 评论 -
HDU - 5877 Weak Pair (dfs+线段树)
Weak PairTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 5233 Accepted Submission(s): 1521Problem DescriptionYou are given a rooted tr...原创 2018-08-31 21:33:16 · 212 阅读 · 0 评论 -
CodeForces - 786B Legacy (线段树建图+最短路)
B. Legacytime limit per test2 seconds memory limit per test256 megabytes inputstandard inputoutputstandard outputRick and his co-workers have made a new radioactive formula and a lot of bad guys...原创 2018-08-29 13:32:27 · 818 阅读 · 0 评论 -
POJ - 2886 Who Gets the Most Candies? (线段树+反素数)
题意:有个小盆友围成一圈,从第个小朋友开始,选中谁谁退圈,每个小朋友都有一个数,这个数为正数表明下一个选中的小朋友即为这个小朋友左边第个小朋友,为负数表明下一个选中的小朋友为这个小朋友右边第个小朋友。每个小朋友退圈即可获得的因子数的糖果数,为这个小朋友是第几个退圈的,输出这个获得最多的糖果的小朋友的名字和她获得的糖果数。思路:个小朋友,获得最多的糖果的那个人的编号为中有最多因子数的那个数,所以...原创 2019-05-18 09:41:58 · 328 阅读 · 0 评论 -
STL-bitset
原文章链接:https://www.cnblogs.com/RabbitHu/p/bitset.htmlbitset存储二进制数位。bitset就像一个bool类型的数组一样,但是有空间优化——bitset中的一个元素一般只占1 bit,相当于一个char元素所占空间的八分之一。bitset中的每个元素都能单独被访问,例如对于一个叫做foo的bitset,表达式foo[3]访问了它的第...转载 2018-10-30 17:00:44 · 183 阅读 · 0 评论 -
POJ-2991 Crane(线段树)
题意:给出n条线段,开始时n条线段一词首尾相连,与地面垂直,c次操作,每次操作给出,,让线段和之间德角度变为度,并输出第n条线段的前端坐标。思路:线段树,区间存储的线段的向量坐标,父亲节点的向量坐标就等于儿子节点的向量坐标相加,在存储一个角度变量,类似于懒惰标记的作用,将一条线段逆时针旋转v度后的坐标为顺时针:#include <math.h>#incl...原创 2019-05-16 21:40:47 · 304 阅读 · 0 评论 -
POJ - 3171 Cleaning Shifts(DP+线段树优化)
题意:头牛,每头牛在到时间段干活并需要数量的钱,想要在到时间段的每一时刻都有牛在干活,最少需要多少钱?思路:首先把不在到时间段干活的牛给去除,在把剩下的牛按照从小到大排序,表示从到都有牛干活的最下花费,挨个遍历每个时间段,有: 其中找最小值部分可以用线段树来优化#include <...原创 2019-05-21 19:44:25 · 335 阅读 · 0 评论 -
HDU - 4821 String(hash+map去重)
StringTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4430 Accepted Submission(s): 1341Problem DescriptionGiven a string S and two inte...原创 2018-10-07 11:11:57 · 243 阅读 · 0 评论 -
HDU 4819 Mosaic(二维线段树)
MosaicTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 2691 Accepted Submission(s): 1183Problem DescriptionThe God of sheep decides t...原创 2018-10-07 10:49:31 · 244 阅读 · 0 评论 -
STL中有用的函数
去掉string的最后一个字符s.pop_back();s.pop_back();s=s.substr(0,s.length()-1);原创 2018-09-22 19:42:10 · 214 阅读 · 0 评论 -
HDU - 5542 The Battle of Chibi (dp+二维树状数组优化)
The Battle of ChibiTime Limit: 6000/4000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2882 Accepted Submission(s): 1034Problem DescriptionCao Cao made up a...原创 2018-10-11 19:11:10 · 187 阅读 · 0 评论 -
ZOJ - 3261 Connections in Galaxy War (逆向并查集)
Connections in Galaxy WarTime Limit: 3 Seconds Memory Limit: 32768 KBIn order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to...原创 2018-10-02 10:03:38 · 186 阅读 · 0 评论 -
HDU 5536 Chip Factory(字典树)
Chip FactoryTime Limit: 18000/9000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 5258 Accepted Submission(s): 2358Problem DescriptionJohn is a manager of ...原创 2018-10-01 19:06:05 · 259 阅读 · 0 评论 -
HDU - 5971 Wrestling Match (种类并查集)
Wrestling MatchTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3367 Accepted Submission(s): 1210Problem DescriptionNowadays, at least o...原创 2018-09-18 21:18:24 · 344 阅读 · 0 评论 -
HDU 6215 Brute Force Sorting(双向链表+队列)
Brute Force SortingTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 2304 Accepted Submission(s): 539Problem DescriptionBeerus needs to s...原创 2018-09-13 16:06:36 · 274 阅读 · 0 评论 -
ACM-ICPC 2018 焦作赛区网络预赛 H. String and Times (后缀自动机&后缀数组)
Now you have a string consists of uppercase letters, two integers AA and BB. We call a substring wonderful substring when the times it appears in that string is between AA and BB (A \le times \le BA≤t...原创 2018-09-15 18:49:54 · 545 阅读 · 0 评论 -
CSU 1457 Boggle (字典树+DFS)
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1457读了一遍题想到了字典树,但不知道怎么写,队友一个单词一个单词的枚举,然后暴搜过了,赛后查题解发现就是字典树+暴搜,比队友写的少了几百毫秒#include <bits/stdc++.h>using namespace std;int trie_n;con...原创 2018-09-04 20:33:21 · 277 阅读 · 0 评论 -
2018 ACM-ICPC南京网络赛 Lpl and Energy-saving Lamps(线段树)
During tea-drinking, princess, amongst other things, asked why has such a good-natured and cute Dragon imprisoned Lpl in the Castle? Dragon smiled enigmatically and answered that it is a big secret. A...原创 2018-09-01 18:41:11 · 383 阅读 · 0 评论 -
ZOJ 3765 Lights (伸展树)
LightsTime Limit: 8 Seconds Memory Limit: 131072 KBNow you have N lights in a line. Don't worry - the lights don't have color. The only status they have is on and off. And, each light has a...原创 2018-08-03 19:16:56 · 171 阅读 · 0 评论 -
BZOJ 1483 梦幻布丁( 启发式合并)
DescriptionN个布丁摆成一行,进行M次操作.每次将某个颜色的布丁全部变成另一种颜色的,然后再询问当前一共有多少段颜色.例如颜色分别为1,2,2,1的四个布丁一共有3段颜色.Input第一行给出N,M表示布丁的个数和好友的操作次数. 第二行N个数A1,A2...An表示第i个布丁的颜色从第三行起有M行,对于每个操作,若第一个数字是1表示要对颜色进行改变,其后的两...原创 2018-07-29 12:35:08 · 350 阅读 · 0 评论 -
杭电多校第二场 Naive Operations(线段树区间更新+单点更新)
Naive OperationsTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 502768/502768 K (Java/Others)Total Submission(s): 2369 Accepted Submission(s): 1040 Problem DescriptionIn a galax...原创 2018-07-28 21:22:10 · 190 阅读 · 0 评论 -
POJ - 1703 Find them, Catch them (并查集)
POJ - 1703 Find them, Catch them (并查集) 这道题与食物链那一道题是同一类型的,但稍微简单些,题意就不说了 比普通的并查集多了一个relation [i]数组,记录与父亲节点的关系,在并查集里的元素都是已经它们之间的关系的,在路径压缩与集合合并时不断的更新relation数...原创 2017-08-27 20:21:59 · 362 阅读 · 0 评论 -
POJ1182 食物链 (带权并查集)
POJ1182 食物链 (带权并查集) 一看见这道题就想到了并查集,但是普通的并查集根本行不通,因为通过普通的并查集我们只能得出两个元素是否在同一个集合与把两个集合合并为一个集合,这道题既有种类之分,各个种类之间还有同类、吃、被吃的关系。限时训练结束后学长说这道题用带权并查集,百度了n个博客,才有了点头绪。 首先,带权并差集比普通的并查集多了一个权值(关系),普通并查集只用了一个pre数组...原创 2017-08-27 19:52:38 · 478 阅读 · 0 评论 -
Codeforces 505B - Mr. Kitayuta's Colorful Graph DFS或并查集
Codeforces 505B - Mr. Kitayuta's Colorful Graph一个无向图包含n个点m条边,顶点编号从1到n。 对于每条边有颜色ci, 连接着顶点 ai 和 b i. 下面有q个询问.每条询问有两个整数 — ui 和 vi.找到满足下面条件的颜色个数: 同一种颜色的路径连接顶点 ui 和 顶点 vi Input第一行是两个整数 — n and m (2 ≤...原创 2017-08-13 10:26:03 · 305 阅读 · 0 评论