题目链接: http://poj.org/problem?id=2083题目描述: n = 1时,图形b[1]是X n = 2时,图形b[2]是X X X X X 所以n时,图形b[n]是b[n-1] b[n-1] ...
分类:
其他好文 时间:
2014-12-17 18:08:06
阅读次数:
169
题目链接:http://poj.org/problem?id=1017
Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 44985
Accepted: 15208
Description
A factory produces products packed in ...
分类:
其他好文 时间:
2014-12-17 16:33:48
阅读次数:
238
题目链接:点击打开链接
求两条路径的交点的个数(保证路径唯一)深搜一发。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define maxn 100010
#define _ll...
分类:
其他好文 时间:
2014-12-17 16:32:05
阅读次数:
151
题目来源于POJ,是一道非常基础的动态规划题目。但是却耗费了我非常多的时间,时间复杂度也从N的三次方,降到N的平方,最后优化到0(n)才最终得以通过。
题目如下:
要求其实非常简单,已知给你a1,a2....an,总共n个数,要求你从中抽取出两个连续的子序列,当然,如题意所示,两个序列连续在一起也是OK的,然后将其中最大的序列和输出即可。
看到题目,第一想法非常简单,从n个数中选择一个数...
分类:
其他好文 时间:
2014-12-17 16:29:36
阅读次数:
229
题目链接:https://oj.leetcode.com/problems/min-stack/
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
push(x) -- Push element x onto stack.pop(...
分类:
其他好文 时间:
2014-12-17 16:28:46
阅读次数:
181
题目
Given a set of candidate numbers (C) and a target number (T), find all unique combinations
in C where the candidate numbers sums to T.
The same repeated number may be chosen from C unlimi...
分类:
其他好文 时间:
2014-12-17 16:26:21
阅读次数:
170
题目描述: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 l...
分类:
其他好文 时间:
2014-12-17 16:10:40
阅读次数:
167
题意:
给n个人和一些认识关系,要将这n个人分成两队,每队的人之间都互相认识,求一种方案使两队的人数差最小。
分析:
对原图求逆得到新图g,g中如果有边(a,b),那么a,b不能在一个队,对新图进行二分图染色就能求得一种方案了。但题目要使人数差最小,所以还要dp一下。dp[i][j]表示前i个连通分量获得j个人的队伍是否可行,这其实是个背包问题,每个物品有多种重量,问是否能获得一个特定的重量...
分类:
其他好文 时间:
2014-12-17 14:43:23
阅读次数:
126
【题目】
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
For example,
[1,1,2] have the following unique permutations:
[1,1,2], [1,2,1],
an...
分类:
其他好文 时间:
2014-12-17 12:49:36
阅读次数:
140
题目链接: http://poj.org/problem?id=1164题目描述: 有一个n*m的castle,有一个个小房间组成,每个房间由一个零和四面的墙组成,每个房间都有一个价值,价值的计算方式是:west_walls价值为1,north_walls价值为2,east_walls价值为4,.....
分类:
其他好文 时间:
2014-12-17 12:18:54
阅读次数:
180