Given a string S, find the longest palindromic
substring in S. You may assume that the maximum length of S is 1000, and there
exists one unique longes...
分类:
其他好文 时间:
2014-05-24 04:45:39
阅读次数:
245
10192 最长公共子序列
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&
Itemid=8&page=show_problem&category=114&problem=1133&mosmsg=
Submission...
分类:
其他好文 时间:
2014-05-23 22:30:07
阅读次数:
528
Given a binary tree, find its maximum depth.The
maximum depth is the number of nodes along the longest path from the root node
down to the farthest le...
分类:
其他好文 时间:
2014-05-23 11:54:10
阅读次数:
317
MSS(Array[],N)//Where N is the number of
elements in array{sum=0; //current summax-sum=0;//Maximum Sumseq-start=0;//start
of the subsequenceseq-end=0;...
分类:
其他好文 时间:
2014-05-23 11:03:58
阅读次数:
221
题目大意:
输入一个文章,[ 就是把光标放到最前面 ] 把光标放到最后面。
输出最后得到的文章。
思路分析:
用deque 模拟。
#include
#include
#include
#include
#define maxn 111111
using namespace std;
char str[maxn];
deque Q;
deque::itera...
分类:
其他好文 时间:
2014-05-23 08:12:11
阅读次数:
335
题目大意:
超时进行促销,把账单放入一个箱子里
每次拿取数额最大的和最小的,给出 最大-最小 的钱。
问n天总共要给出多少钱。
思路分析:
multiset 上直接进行模拟
注意要使用long long
而且multiset的删除要用 迭代器。
#include
#include
#include
#include
#include
#define m...
分类:
其他好文 时间:
2014-05-23 08:11:38
阅读次数:
224
uva 548 Tree
题目大意:
给定一个二叉树的中序和后序遍历,求二叉树到每个叶节点的路径和最小的那个叶节点的值。
解题思路:
先建树,后dfs,建树也就是后序的最后一个就是二叉树的当前节点的值,再在中序中找到这个值,那么左边就是左子树,右边就是又子树,再从后序中找出相应的左右子树的后序,然后划分为子问题递归求解。...
分类:
其他好文 时间:
2014-05-23 08:10:59
阅读次数:
255
【题目】
Bob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees, factories and...
分类:
其他好文 时间:
2014-05-22 13:09:50
阅读次数:
247
Description
You are given a string consisting of parentheses () and []. A string of this type is said to be correct:
(a)if it is the empty string(b)if A and B are correct, AB is correct,(c)...
分类:
其他好文 时间:
2014-05-22 09:53:27
阅读次数:
295
UVA 10237 - Bishops
题目链接
题意:问一个n * n棋盘能放k个主教(攻击斜线)的方案数。
思路:递推,首先考虑一个问题,在一个n?n棋盘上,放k个车的方案数。
那么设dp[i][j]为i行用了j个车的方案数,由于每行只能放一个车,那么考虑i行放不放车,如果放车,那么能放的位置有n?(j?1)个位置,为dp[i?1][j?1]?(n?(j?1))。
如果不放那...
分类:
其他好文 时间:
2014-05-22 07:57:05
阅读次数:
148