随笔分类 - 数据结构
摘要:BaoBao has just found a rooted tree with n vertices and (n-1) weighted edges in his backyard. Among the vertices, m of them are red, while the others
阅读全文
摘要:Yixght is a manager of the company called SzqNetwork(SN). Now she's very worried because she has just received a bad news which denotes that DxtNetwor
阅读全文
摘要:背单词,始终是复习英语的重要环节。在荒废了3年大学生涯后,Lele也终于要开始背单词了。 一天,Lele在某本单词书上看到了一个根据词根来背单词的方法。比如"ab",放在单词前一般表示"相反,变坏,离去"等。 于是Lele想,如果背了N个词根,那这些词根到底会不会在单词里出现呢。更确切的描述是:长度
阅读全文
摘要:Andy the smart computer science student was attending an algorithms class when the professor asked the students a simple question, "Can you propose an
阅读全文
摘要:描述 后缀数组 (SA) 是一种重要的数据结构,通常使用倍增或者DC3算法实现,这超出了我们的讨论范围。在本题中,我们希望使用快排、Hash与二分实现一个简单的 O(n log^2n ) 的后缀数组求法。详细地说,给定一个长度为 n 的字符串S(下标 0~n-1),我们可以用整数 k(0≤k<n)
阅读全文
摘要:描述 很久很久以前,森林里住着一群兔子。有一天,兔子们想要研究自己的 DNA 序列。我们首先选取一个好长好长的 DNA 序列(小兔子是外星生物,DNA 序列可能包含 26 个小写英文字母),然后我们每次选择两个区间,询问如果用两个区间里的 DNA 序列分别生产出来两只兔子,这两个兔子是否一模一样。注
阅读全文
摘要:You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true. Your program will read
阅读全文
摘要:描述 给定一个长度为 n 的序列 A,A 中的数各不相同。对于 A 中的每一个数 A_i,求: min(1≤j<i) |A_i-A_j| 以及令上式取到最小值的 j(记为 P_i)。若最小值点不唯一,则选择使 A_j 较小的那个。 输入格式 第一行一个整数n,第二行n个数A_1~A_n。 输出格式
阅读全文
摘要:描述 输入一个长度为n的整数序列,从中找出一段不超过m的连续子序列,使得整个序列的和最大。 例如 1,-3,5,1,-2,3 当m=4时,S=5+1-2+3=7 当m=2或m=3时,S=5+1=6 输入格式 第一行两个数n,m(n,m<=300000) 第二行有n个数,要求在n个数找到最大子序和 输
阅读全文
摘要:Queues and Priority Queues are data structures which are known to most computer scientists. The Team Queue, however, is not so well known, though it o
阅读全文
摘要:Description 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
阅读全文
摘要:Problem Description Sample Input 8 I 2 I -1 I 1 Q 3 L D R Q 2 8 I 2 I -1 I 1 Q 3 L D R Q 2 Sample Output 2 3 Hint The following diagram shows the stat
阅读全文
摘要:前缀表达式:op a b 中缀表达式:a op b 后缀表达式 a b op 1、对于计算单独的后缀表达式较为简单,从左到右,遇到数字将其压入栈内,遇到操作符从栈中取出两个数进行相应操作,结果再次压入栈内。 2、对于前缀表达式的计算和后缀相似,从右到左的顺序,剩下和后缀一致 3、对于中缀表达式,我们
阅读全文
摘要:For this problem, you will write a program that reads in a sequence of 32-bit signed integers. After each odd-indexed value is read, output the median
阅读全文

浙公网安备 33010602011771号