
STL
爱吃老谈酸菜的DV
选择适合自己的。
展开
-
STL的模板
一、栈(stack)头文件:<stack>定义:stack<date_type>stack_name;操作:s.empty();//返回bool类型,表示栈内是否为空s.size();//返回栈元素个数s.top();//返回栈顶元素s.pop();//移除栈顶元素s.push(a);//向栈内压入一个元素a二、队列(queue)1.头文件:2.定义...原创 2019-04-30 23:37:22 · 240 阅读 · 0 评论 -
CodeForces - 252B: Unsorting Array(思维,STL,有个地方不太懂)
DiscriptonLittle Petya likes arrays of integers a lot. Recently his mother has presented him one such array consisting of n elements. Petya is now wondering whether he can swap any two distinct integ...原创 2019-08-10 23:35:33 · 230 阅读 · 0 评论 -
2019年7月27日训练日记(单调栈、单调队列)
今天太热了,热到不想动,感觉书也没看进去多少,上午补了几道题,下午看明白了单调栈和单调队列。1.单调栈:题目:给定n个不同高度的矩形,求最大的联通的矩形的面积。单调栈的做法就是:从头开始将矩形入栈,遇到比栈顶矩形高的就入栈,同时计算不同面积的情况取最大值;遇到比栈顶矩形矮的就把栈内元素全部出栈;然后重复这个操作,就可以找到最大值。2.单调队列:题目:给定一行数,要在里面找一个子串,求使...原创 2019-07-27 23:30:31 · 151 阅读 · 0 评论 -
2018年7月26日训练日记(栈、队列)
今天上午补了半上午的题,补完题之后又继续看《算法竞赛进阶指南》。开始觉得栈挺简单的,就是只有一个出口,进栈出栈操作都只能在一端进行,后来发现还是我太天真。表达式计算:1.后缀表达式:是遇到数字则把数字入栈,遇到运算符则将栈顶两个元素出栈运算。2.中缀表达式:是遇到数则输出该数;遇到左括号则左括号入栈,遇到右括号,不断取出元素进行计算,然后左括号出栈,将新得到的数入栈;遇到运算符,若栈顶符...原创 2019-07-27 09:27:08 · 140 阅读 · 0 评论 -
CodeForces - 224C:Bracket Sequence(STL,栈)
DiscriptionA bracket sequence is a string, containing only characters “(”, “)”, “[” and “]”.A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic express...原创 2019-07-27 11:21:20 · 240 阅读 · 0 评论 -
CodeForces - 222D:Olympiad(STL,贪心)
DiscriptionA boy named Vasya has taken part in an Olympiad. His teacher knows that in total Vasya got at least x points for both tours of the Olympiad. The teacher has the results of the first and th...原创 2019-07-26 23:08:42 · 217 阅读 · 0 评论 -
STL知识点总结
一、栈(stack)1.特点:先进后出,只有一个出口,只能操作顶端元素。2:头文件:3.定义:stac&amp;amp;lt;date_type&amp;amp;gt;stack_name;(stack是整体类型,date_type是元素类型)eg:stacks;4.常用操作:s.empty():返回bool类型,表示栈内是否为空s.size():返回栈元素个数s.top():返回栈顶元素s.pop():移除栈...原创 2019-03-02 22:36:24 · 456 阅读 · 0 评论 -
STL-V解题报告
题目:Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence1, 2, 3, 4, 5, 6, 8, 9, 10, 12, …shows the first 10 ugly numbers. By convention, 1 is included.Given the integer n,w...原创 2019-03-02 23:22:49 · 154 阅读 · 0 评论 -
STL-J解题报告
题目:Now our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the BEelzebub has to beat our hero first. feng5166 says, “I...原创 2019-03-06 23:42:18 · 206 阅读 · 0 评论 -
STL用法总结
一、vectorvector是向量,也是动态数组。顾名思义,vector的性质和数组类似,但是vector的大小可以改变。对于某些问题,若一开始不知道应该定义的数组的大小,可以定一个动态数组,以改变数组大小,防止出现数组访问越界的问题。数组用来存储字符串的方式是使用字符数组,即char类型的数组,字符数组中的每一个元素都是一个字符,无法同时存储多个字符串,vector动态数组就解决了这个问题。...原创 2019-03-09 23:02:47 · 246 阅读 · 0 评论 -
单调队列基本概念
一、概念队列中元素之间的关系具有单调性,而且,队首和队尾都可以进行出队操作,只有队尾可以进行入队操作。二、操作(1)插入:若新元素从队尾插入后会破坏单调性,则删除队尾元素,直到插入后不再破坏单调性为止,再将其插入单调队列。(2)获取最优(最大、最小)值:访问首尾元素。三、实现举例(1,3,2,1,5,6),进入单调不减队列的过程:开始队列为空;1入队,得到队列(1);3入队,因为...原创 2019-06-09 15:07:45 · 199 阅读 · 0 评论