Sorting It All Out
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 27929
Accepted: 9655
Description
An ascending sorted sequence of distinct values is on...
分类:
其他好文 时间:
2014-08-26 19:40:46
阅读次数:
194
题目大意:
有一串只含有 "(" ")" "[" "]" 的序列,问在该序列的 左右括号能分别配对的 所有子串中的含有方括号的个数的最大值,并输出相对应的子串。
做法:
利用一个栈来维护,每次如果有能与栈顶的元素配对的右边括号时,将该元素弹出,如果此时弹出的元素代表方括号,那么记录此时出现的下标。否则将该元素压进栈。
当然我们压进栈的是当前元素的下标。当处理完整个序列之后...
分类:
其他好文 时间:
2014-08-26 17:30:46
阅读次数:
151
http://acm.timus.ru/problem.aspx?space=1&num=1081
有一个二进制序列,定义为不能有两个连续的1出现,才是合法的。给出序列的长度n,求合法的二进制序列中按字典序排序后第k个序列是什么。
设dp[i][0]和dp[i][1]分别表示第i位上是0和1的个数。
那么dp[i][0] = dp[i-1][0] + dp[i-1][1];d...
分类:
其他好文 时间:
2014-08-26 17:25:56
阅读次数:
209
Description
You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order.
In addition to that, you are given several queries consisting of indices
i and j (1 ≤ i ≤ j ≤ n). ...
分类:
其他好文 时间:
2014-08-26 17:24:06
阅读次数:
333
给一串由(,
), [ ,]构成的字符串,求包含[最多的合法子串
很容易,先把整个字符串丢入栈里处理
栈的每一个元素存两个东西,字符,在字符串中的位置
处理方式为如果是()匹配则直接丢弃,如果是[]匹配则在这个点vis[i]++,然后求vis的前缀和
如果栈空,则说明整个串是合法的,直接输出串
否则,扫描栈中剩下的元素的位置,这几个位置把整个原串切割成几段,这几段肯定是合法的,求这...
分类:
其他好文 时间:
2014-08-26 13:41:36
阅读次数:
198
http://acm.timus.ru/problem.aspx?space=1&num=1183
很经典的问题吧,看的黑书上的讲解。
设dp[i][j]表示i到j括号合法需要的最少括号数。
共有四种情况:
s[i]s[j]配对,dp[i][j] = min( dp[i][j] , dp[i-1][j+1] );
s[i] = '('或'[' dp[i][j] = min( d...
分类:
其他好文 时间:
2014-08-26 11:42:55
阅读次数:
206
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence ...
分类:
其他好文 时间:
2014-08-25 22:49:25
阅读次数:
274
题意 求一个序列a某一位的最长递增序列(lis)和最长递减序列(lds)中最小值的最大值
开始直接用DP写了 然后就超时了 后来看到别人说要用二分把时间复杂度优化到O(n*logn) 果然如此 用一个栈s保存长度为i的LIS的最小尾部s[i] top为栈顶即当前LIS的长度 初始s[1]=a[1] top=1 遍历整个序列 当a[i]>s[top]时 a[i]入栈
...
分类:
其他好文 时间:
2014-08-25 17:10:14
阅读次数:
258
Goffi and Median
Problem Description
A median in a sequence with the length of n is an element which occupies position number ?n+12? after we sort the elements in the non-decreasing order ...
分类:
其他好文 时间:
2014-08-25 11:55:34
阅读次数:
159
题目描述:
Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14} is 12, and the median of S2={9, 10, 15, 16, 17} is 15. The median of two sequences is defined to be...
分类:
其他好文 时间:
2014-08-24 19:24:22
阅读次数:
235