基本数据结构
文章平均质量分 62
fsz-blog
这个作者很懒,什么都没留下…
展开
-
单调递减队列
题意:给定一个长度为n的序列,有一个长度为k的滑动窗口,窗口从左向右依次移动,求每次移动时窗口中的最大值。算法实现:1.有一种很常见的算法,时间复杂度为O(n*k)的算法,线性遍历每个数再求每个滑动窗口中的最大值,、但当k很大的时候非常耗时。2.还有一中就是单调递减队列,可以把时间复杂度优化到接近O(n),既然是单调队列,那我们就要定义一个队列,而且还要是双端的。下面我们模原创 2016-09-24 16:30:57 · 936 阅读 · 0 评论 -
Babelfish
Babelfish题目描述:You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.原创 2017-05-16 11:29:44 · 382 阅读 · 0 评论 -
Crazy Search
Crazy Search题目描述:Many people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a given text. Such number could be the number o原创 2017-05-15 21:15:52 · 406 阅读 · 0 评论 -
Web Navigation
Web Navigation题目描述:Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pa原创 2017-05-15 21:06:28 · 315 阅读 · 0 评论 -
Rails
Rails题目描述:There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was poss原创 2017-05-15 20:55:24 · 277 阅读 · 0 评论 -
Tanning Salon
Tanning Salon题目描述:Tan Your Hide, Inc., owns several coin-operated tanning salons. Research has shown that if a customer arrives and there are no beds available, the customer will turn around and leave,原创 2017-05-15 20:47:55 · 362 阅读 · 0 评论 -
士兵队列训练问题
士兵队列训练问题题目描述: 某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序号方向靠拢,继续从头开始进行一至二报数。。。,以后从头开始轮流进行一至二报数、一至三报数直到剩下的人数不超过三人为止。Input本题有多个测试数据组,第一行为组数N,接着为原创 2017-05-15 20:44:42 · 994 阅读 · 0 评论 -
Areas on the Cross-Section Diagram
Areas on the Cross-Section Diagram Aizu - ALDS1_3_D Areas on the Cross-Section Diagram地域の治水対策として、洪水の被害状況をシミュレーションで仮想してみよう。 図のように $1 \times 1 (m^2)$ の区画からなる格子上に表された地域の模式断面図が与えられるので、地域にできる各原创 2016-12-09 10:04:48 · 963 阅读 · 0 评论 -
链表(裸题)
Doubly Linked List Aizu - ALDS1_3_C Your task is to implement a double linked list. Write a program which performs the following operations: insert x: insert an element with key x into原创 2016-12-09 09:46:20 · 304 阅读 · 0 评论 -
栈(裸题)
Stack Aizu - ALDS1_3_AWrite a program which reads an expression in the Reverse Polish notation and prints the computational result.An expression in the Reverse Polish notation is calc原创 2016-12-09 09:32:09 · 477 阅读 · 0 评论 -
队列(裸题)
Queue Aizu - ALDS1_3_B For example, we have the following queue with the quantum of 100ms. A(150) - B(80) - C(200) - D(200)First, process A is handled for 100ms, then the process is moved原创 2016-12-09 09:40:03 · 250 阅读 · 0 评论 -
Cube Stacking
Cube StackingFarmer John and Betsy are playing a game with N (1 <= N <= 30,000)identical cubes labeled 1 through N. They start with N stacks, each containing a single cube. Farmer John asks Betsy to pe原创 2017-05-16 11:43:25 · 340 阅读 · 0 评论