随笔分类 - 数据结构—STL
1
摘要:做了一些链表的题,总结一下,对于链表,处理方式有两种,一是处理节点的值,而是处理节点,比如增加,删除,交换节点等。常用的技巧:双指针求环,求链表交点,求特殊点(中点、倒数第几个点等)。
阅读全文
摘要:ps:单调栈,注意红色部分的代码。
阅读全文
摘要:题解:从前往后,维护一个从栈底到栈顶递增的栈,那么每个区间的最小值就是栈底。从后往前,维护一个从栈顶到栈底递增的栈,那么每个区间的最大值就是栈底。
阅读全文
摘要:PS:怎么没想到从后往前做呢。。。紫书上做过类似的题,滑动窗口。如果当前元素比栈顶元素大,则不断弹出栈顶元素直到栈顶元素比当前元素小,然后把当前元素压入栈中。如果当前元素比栈顶元素小,则直接入栈。如果当前栈中有元素不再当前区间中,则不断弹出栈底元素。每段区间最大值就是栈底元素,递增个数就是栈的大小。
阅读全文
摘要:Distinct Values PS:思路巨明显,就是代码写不出,总想着一次更新一条线段。这里用一个set,存的是当前能用的数的。怎么去更新set,记录上一个区间的左右端点 l , r ,然后类似于莫队的写法。。。。看代码吧。注意上一个区间和当前区间没有公共端点时要特判!!!,也就是代码中的 if
阅读全文
摘要:题意:n个数,m个信息:L,R,k。每个信息表示a[L]^a[L+1]^a[L+2]^····^a[R]=k。如果第 i 个信息与前面 i-1 个信息矛盾的话就输出 i ,如果这m个信息都不矛盾的话,输出 -1 题解:位运算多半要考虑二进制,这里将k分解成二进制形式。先令dp[i][j]表示第i个数
阅读全文
摘要:动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种
阅读全文
摘要:Little X has n distinct integers: p1, p2, ..., pn. He wants to divide all of them into two sets A and B. The following two conditions must be satisfie
阅读全文
摘要:There are some ambiguities when one writes Berland names with the letters of the Latin alphabet. For example, the Berland sound u can be written in th
阅读全文
摘要:Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the pr
阅读全文
摘要:A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24
阅读全文
摘要:调了好久,orz 题解:以从大到小的顺序,先把大的翻到最上面,然后再翻回它应该在的位置(即从小到大的排序中的位置),不懂的话拿笔模拟这个过程就明白了。 注意读入的方法!!!坑了好久
阅读全文
摘要:好难得调试!!!!!! 正解: 枚举a串的长度,然后在枚举的串尾添加一个字符使满足大小关系.
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int maxn=1000005; 9 10 int T,n; 11 int a[maxn]; 12 13 int main() 14 { cin>>T; 15 while(T--){...
阅读全文
摘要:The cows play the child's game of hopscotch in a non-traditional way. Instead of a linear set of numbered boxes into which to hop, the cows create a 5
阅读全文
摘要:题意:有t个团队的人正在排一个长队。每次新来一个人时,如果他有队友在队伍里,那么这个新人会插队到最后一个队友的身后;否则他就排到长队的末尾。 ENQUEUX x: 编号为x人进入长队。 DEQUEUX: 长队的队首出队。 STOP: 停止模拟。 用两个队列,一个是长队,一个是各个团队的队列。
阅读全文
摘要:ManyareasofComputerScienceusesimple,abstractdomainsforbothanalyticalandempiricalstudies. For example, an early AI study of planning and robotics (STRI
阅读全文
摘要:In a serious attempt to downsize (reduce) the dole queue, The New National Green Labour Rhinoceros Party has decided on the following strategy. Every
阅读全文
摘要:A children’s puzzle that was popular 30 years ago consisted of a 5×5 frame which contained 24 small squares of equal size. A unique letter of the alph
阅读全文
摘要:As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in th
阅读全文
1
![](https://images.cnblogs.com/cnblogs_com/zgglj-com/1682556/o_200327152908zg.jpg)