题目:Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (includin....
分类:
编程语言 时间:
2014-08-06 04:10:50
阅读次数:
325
题目链接:hdu 4915 Parenthese sequence
题目大意:给定一个序列,由(,),?组成?可以表示(或者),问说有一种、多种或者不存在匹配。
解题思路:从左向右,从右向左,分别维护左括号和右括号可能的情况,区间上下界。如果过程中出现矛盾,则为None,否则要判断唯一解还是多解。枚举每个问号的位置,假设该问号可为左右括号,则有多解。
#include
#inclu...
分类:
其他好文 时间:
2014-08-06 02:05:00
阅读次数:
310
HDU 4915 Parenthese sequence
题目链接
题意:给定一个有?的左右括号串,?能替代为'('或')',问括号匹配是否唯一或多种或不可能
思路:先从右往左扫一边,维护一个up, down表示当前位置右边右括号剩余个数的上限和下限,如果维护完后起始位置的下限为0,那么就是可以的,因为为0就代表没有多余的右括号。然后在从左往右扫一遍,和上面一样的处理,只是遇到每...
分类:
其他好文 时间:
2014-08-06 02:03:40
阅读次数:
260
题目:Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can b....
分类:
编程语言 时间:
2014-08-06 01:52:30
阅读次数:
251
题目:Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter...
分类:
编程语言 时间:
2014-08-06 01:35:30
阅读次数:
389
HDU 4911 Inversion
题意:n个数字 通过k次相邻交换 使得逆序对数最少
思路:如果序列为 XXXABYYY 假设A和B位置互换 易知X和AB、Y和AB的逆序对数不变 换句话说一次交换最多使逆序对减少1 那么只需要求原逆序对数和k进行比较即可
HDU 4915 Parenthese sequence
题意:?可以代表(或) 那么输入的字符串能构造出几种合法的括号序列呢 输出无解、唯一解、多解
思路:这题是我YY的… 首先我们可以计算出(和)应该填几个 如果计算出?不满足我...
分类:
其他好文 时间:
2014-08-05 22:48:20
阅读次数:
289
Problem Description
bobo has a sequence a1,a2,…,an. He is allowed to swap two
adjacent numbers for no more than k times.
Find the minimum number of inversions after his swaps.
Note: The number...
分类:
其他好文 时间:
2014-08-05 22:44:03
阅读次数:
248
KMP查找整数数列,不是查找字符串。
原理是一样的,不过把字符串转换为数列,其他基本上是一样的。
#include
#include
const int MAX_N = 1000001;
const int MAX_M = 10001;
int strN[MAX_N], strM[MAX_M], next[MAX_M], N, M;
void getNext()
{
mems...
分类:
其他好文 时间:
2014-08-05 22:37:10
阅读次数:
194
hdu4915Parenthese sequenceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 82 Accepted Submissi...
分类:
其他好文 时间:
2014-08-05 22:09:00
阅读次数:
673
呵呵不是我做的
#include
#include
#include
const int N = 1000000 + 10;
char s[N];
int d[N], num[N];
int main() {
while (~scanf("%s", s)) {
memset(num, 0, sizeof num);
int len = strlen...
分类:
其他好文 时间:
2014-08-05 19:25:10
阅读次数:
218