![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
文章平均质量分 57
CNG Steve·Curcy
death is what gives life meaning, to know your days are numbered,your time is short.
展开
-
POJ - 1743 Musical Theme(后缀数组+二分)
A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1…88, each representing a key on the piano. It is unfortunate but true that this representat...原创 2019-09-06 17:14:08 · 115 阅读 · 0 评论 -
Table with Letters - 2(dp & 队列思想)
Vasya has recently started to learn English. Now he needs to remember how to write English letters. He isn’t sure about some of them, so he decided to train a little.He found a sheet of squared paper...原创 2019-07-23 13:58:37 · 129 阅读 · 0 评论 -
Codeforce #576 D. Welfare State(线段树)
There is a country with n citizens. The i-th of them initially has ai money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they...原创 2019-08-01 09:40:54 · 687 阅读 · 0 评论 -
CodeForces 144C - Anagram Search(哈希算法)
A string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string “aab” is an anagram of the string “aba” an...原创 2018-10-15 09:24:07 · 251 阅读 · 0 评论 -
HDU - 1166 - 敌兵布阵(线段树基础操作)
HDU - 1166 - 敌兵布阵C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 ...原创 2018-08-09 16:24:20 · 1582 阅读 · 0 评论 -
HDU - 1754 - I Hate It(线段树基础)
HDU - 1754 - I Hate It很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0 ...原创 2018-08-09 16:40:08 · 174 阅读 · 0 评论 -
HDU - 1698 - Just a Hook(线段树基础)
HDU - 1698 - Just a HookIn the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the...原创 2018-08-09 17:03:30 · 652 阅读 · 0 评论 -
OpenJ_Bailian - 2299 - Ultra-QuickSort (树状数组 & 线段树 & 求逆序数)
OpenJ_Bailian - 2299 - Ultra-QuickSortIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence...原创 2018-08-10 10:18:40 · 531 阅读 · 0 评论 -
OpenJ_Bailian - Mayor's posters(线段树 & 离散化)
OpenJ_Bailian - Mayor’s postersThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whi...原创 2018-08-10 21:48:16 · 122 阅读 · 0 评论 -
HDU - 5775 - Bubble Sort(树状数组 & 线段树 & 逆序 & 思维)
HDU - 5775 - Bubble SortBubble SortP is a permutation of the integers from 1 to N(index starting from 1). Here is the code of Bubble Sort in C++. for(int i=1;i<=N;++i) for(int j=N,t;...原创 2018-08-11 10:12:33 · 134 阅读 · 0 评论 -
HDU - 4553 约会安排(线段树)
寒假来了,又到了小明和女神们约会的季节。 小明虽为屌丝级码农,但非常活跃,女神们常常在小明网上的大段发言后热情回复“呵呵”,所以,小明的最爱就是和女神们约会。与此同时,也有很多基友找他开黑,由于数量实在过于巨大,怎么安排时间便成了小明的一大心事。 我们已知小明一共有T的空闲时间,期间会有很多女神或者基友来找小明。 作为一个操作系统曾经怒考71分的大神,小明想到了一个算法,即“首次适应...原创 2019-08-13 15:45:50 · 193 阅读 · 0 评论 -
Physical Education Lessons(线段树动态开点)
This year Alex has finished school, and now he is a first-year student of Berland State University. For him it was a total surprise that even though he studies programming, he still has to attend phy...原创 2019-08-18 16:16:20 · 221 阅读 · 0 评论 -
HDU3333 Turing Tree(线段树 离线处理)
After inventing Turing Tree, 3xian always felt boring when solving problems about intervals, because Turing Tree could easily have the solution. As well, wily 3xian made lots of new problems about in...原创 2019-08-24 16:52:07 · 158 阅读 · 0 评论 -
计蒜客-引爆炸弹(并查集)
在一个 n×m 的方格地图上,某些方格上放置着炸弹。手动引爆一个炸弹以后,炸弹会把炸弹所在的行和列上的所有炸弹引爆,被引爆的炸弹又能引爆其他炸弹,这样连锁下去。现在为了引爆地图上的所有炸弹,需要手动引爆其中一些炸弹,为了把危险程度降到最低,请算出最少手动引爆多少个炸弹可以把地图上的所有炸弹引爆。参考题解并查集的思想,只要记录行号和列号就可以了。然后用并查集并在一起,如果能引爆其他炸弹的...原创 2019-08-31 20:52:41 · 171 阅读 · 0 评论 -
计蒜客 后缀字符串(字典树)
一天蒜头君得到n个字符串Si,每个字符串的长度都不超过 10。蒜头君在想,在这 nnn 个字符串中,以 sis_isi 为后缀的字符串有多少个呢?输入格式第一行输入一个整数 n。接下来 n 行,每行输入一个字符串 Si。输出格式输出 n 个整数,第 i 个整数表示以 Si 为后缀的字符串的个数。参考题解#include <bits/stdc++.h>usin...原创 2019-08-31 19:55:37 · 185 阅读 · 0 评论 -
SPOJ - DISUBSTR Distinct Substrings(后缀数组)
Given a string, we need to find the total number of its distinct substrings.InputT- number of test cases. T<=20;Each test case consists of one string, whose length is <= 1000OutputFor each...原创 2019-08-31 11:55:10 · 122 阅读 · 0 评论 -
HDU - 5877 Weak Pair(dfs序+树状数组)
A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be marked a value of en...原创 2019-08-26 14:56:21 · 95 阅读 · 1 评论 -
Count Color(线段树&状压)
Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem.There is a very long board with length L centimeter, L is...原创 2019-08-16 21:01:41 · 193 阅读 · 0 评论 -
Vases and Flowers(线段树+二分)
Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one flower in one vase. S...原创 2019-08-13 00:26:43 · 377 阅读 · 0 评论 -
线段树扫描线+离散化
A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered ...原创 2019-08-16 10:22:05 · 163 阅读 · 0 评论 -
HDU - 2795 - Billboard(线段树 & 思维)
HDU - 2795 - BillboardAt the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcemen...原创 2018-08-12 13:58:28 · 146 阅读 · 0 评论 -
归并排序
归并排序是所有排序算法中最快的算法了吧,O(nlogn)的时间复杂度,只需要一个辅助数组,就能实现排序;基本思想是分治,这种模式也被引入了CDQ分治。(不知道这么说对不对,因为要学习CDQ才记录一下这个排序)首先我们将整个数据分成两个部分,进行子区间内部排序,当然实现方式与大区间的实现方式一样:分为子区间,直至不能再分。这样,我们就可以保证,我们递归处理完两个子区间的问题之后,两个子区间内部都已...原创 2019-04-15 22:00:51 · 93 阅读 · 0 评论 -
Ultra-QuickSort(CDQ分治+线段树或树状数组)
In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted ...原创 2019-04-17 21:04:41 · 112 阅读 · 0 评论 -
POJ 4047 Garden(线段树)
这个题目,emmm,PDF格式,我复制出来实在是没啥格式可言,这里就不挂题目了。参考题解有n个连续的一维上的点,每个点有一个美丽值。每次有三种操作:1、将x点的美丽值改为y。2、将x、y交换3、查询[x y]间,连续k个点的美丽值总和的最大值。这里我是看的题解的做法,利用线段树,叶子i表示[i i+k]美丽值总和,然后每个点维护一个区间最大值。每个位置向前取k个数,作为这个位置的结果...原创 2018-12-24 20:48:53 · 103 阅读 · 0 评论 -
D-City HDU - 4496(并查集)
Luxer is a really bad guy. He destroys everything he met.One day Luxer went to D-city. D-city has N D-points and M D-lines. Each D-line connects exactly two D-points. Luxer will destroy all the D-lin...原创 2019-01-02 11:36:27 · 164 阅读 · 0 评论 -
A Simple Problem with Integers POJ - 3468(线段树)
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 given interval. The other is to ask for the s...原创 2019-04-09 15:12:33 · 127 阅读 · 0 评论 -
HDU - 1506 - Largest Rectangle in a Histogram (单调栈)
A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows ...原创 2018-09-01 14:43:33 · 181 阅读 · 0 评论 -
D-query(主席树)
Given a sequence of n numbers a1, a2, …, an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in the s...原创 2019-07-30 21:38:15 · 107 阅读 · 0 评论 -
Super Mario(主席树)
Mario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in trouble again and Mario needs to save his lover. We regard the road t...原创 2019-07-30 21:17:01 · 308 阅读 · 1 评论 -
Codeforces 91B Queue(单调队列 线段树)
There are n walruses standing in a queue in an airport. They are numbered starting from the queue’s tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of...原创 2019-07-21 22:51:16 · 300 阅读 · 0 评论 -
牛客竞赛暑期多校训练第二场H-Second Large Rectangle(单调栈)
Given a N×M binary matrix. Please output the size of second large rectangle containing all “1”.题目描述:给定一个大小为n×m的矩阵,矩阵中的元素为1或者0,求这个矩阵中的第二大全1矩阵,如果这个矩阵中全1矩阵的个数不够两个就输出0.其中第二大矩阵可以由最大的生成。(这个在题目里我一直没读到,就一...原创 2019-07-21 10:45:24 · 106 阅读 · 0 评论 -
Interviewe(RMQ )
YaoYao has a company and he wants to employ m people recently. Since his company is so famous, there are n people coming for the interview. However, YaoYao is so busy that he has no time to interview...原创 2019-07-25 09:24:59 · 335 阅读 · 0 评论 -
POJ - 3250 - Bad Hair Day (单调栈)
Some of Farmer John’s N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants to count the number of other cows that can see the top of ...原创 2018-09-02 11:04:51 · 157 阅读 · 0 评论 -
POJ - 2823 - Sliding Window (单调栈)
An array of size n ≤ 10 6 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each tim...原创 2018-09-02 10:05:29 · 326 阅读 · 3 评论 -
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 interact with bugs of the opposite gen...原创 2018-09-01 14:03:54 · 100 阅读 · 0 评论 -
Mayor's posters OpenJ_Bailian - 2528(线段树离散化)
The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally ...原创 2019-04-10 16:29:37 · 143 阅读 · 0 评论 -
Ultra-QuickSort OpenJ_Bailian - 2299(线段树&树状数组求逆序对)
In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted ...原创 2019-04-11 15:20:17 · 167 阅读 · 0 评论 -
Laptop(线段树&非线段树求偏序 牛客网)
FST是一名可怜的小朋友,他很强,但是经常fst,所以rating一直低迷。但是重点在于,他非常适合ACM!并在最近的区域赛中获得了不错的成绩。拿到奖金后FST决定买一台新笔记本,但是FST发现,在价格能承受的范围内,笔记本的内存和速度是不可兼得的。可是,有一些笔记本是被另外一些“完虐”的,也就是内存和速度都不高于另外某一个笔记本,现在FST想统计一下有多少笔记本被“完虐”。题目链接...原创 2019-04-13 00:15:49 · 180 阅读 · 0 评论 -
HDU - 4217 - Data Structure?(线段树)
HDU - 4217 - Data Structure?Data structure is one of the basic skills for Computer Science students, which is a particular way of storing and organizing data in a computer so that it can be used eff...原创 2018-08-11 11:12:47 · 143 阅读 · 0 评论 -
51Nod - 1065 - 最小正子段和(线段树 & 贪心)
51Nod - 1065 - 最小正子段和N个整数组成的序列a11,a22,a33,…,ann,从中选出一个子序列(aii,ai+1i+1,…ajj),使这个子序列的和>0,并且这个和是所有和>0的子序列中最小的。 例如:4,-1,5,-2,-1,2,6,-2。-1,5,-2,-1,序列和为1,是最小的。 Input 第1行:整数序列的长度N(2 <= N <= ...原创 2018-08-12 10:39:36 · 312 阅读 · 0 评论