
动态规划
文章平均质量分 83
旻宇
New Acmer
展开
-
UVA10944 - Nuts for nuts.. 状态压缩
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=21&page=show_problem&problem=1885原创 2014-05-13 21:22:29 · 816 阅读 · 0 评论 -
LeetCode#221 Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0R原创 2015-08-03 14:58:27 · 454 阅读 · 0 评论 -
LeetCode #174 Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially p原创 2015-08-10 11:40:34 · 482 阅读 · 0 评论 -
Leetcode House Robber系列
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house原创 2015-08-07 20:24:53 · 440 阅读 · 0 评论 -
uva10405 - Longest Common Subsequence
URL:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1346原创 2014-07-15 14:56:07 · 436 阅读 · 0 评论 -
leetcode #5 Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length ofS is 1000, and there exists one unique longest palindromic substring.class Solution {public原创 2015-05-17 12:15:44 · 389 阅读 · 0 评论 -
LeetCode Best Time to Buy and Sell Stock 系列
121 Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy原创 2015-05-02 22:55:28 · 474 阅读 · 0 评论 -
POJ2662 A Walk Through the Forest
URL: http://poj.org/problem?id=2662v原创 2014-07-14 13:52:26 · 563 阅读 · 0 评论 -
POJ1185 炮兵阵地
Description司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵部队在地图上的攻击范围如图中黑色区域所示: 如果在地图中的灰色所标识的平原上部署一支炮兵部队,则原创 2014-07-15 13:57:44 · 551 阅读 · 0 评论 -
POJ1458 Common Subsequence
URL : http://poj.org/problem?id=1458原创 2014-07-14 20:54:14 · 408 阅读 · 0 评论 -
uva10910 - Marks Distribution
URL: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1851原创 2014-07-14 15:39:11 · 463 阅读 · 0 评论 -
Codeforces Round #243 (Div. 1) C Sereja and Two Sequences
原题链接 :http://codeforces.com/contest/425/problem/C Sereja and Two SequencesSereja has two sequences a1, a2, ..., an andb1, b2, ..., bm,原创 2014-05-11 11:37:47 · 948 阅读 · 0 评论 -
uva10534 hdu2198 双向LIS问题
LIS问题算是DP中很基础很简单的一类问题,其经典算法时间复杂度为O(n^2);利用它本身的特点,结合二分法,即可设计出时间复杂度为O(n*log n)的优化算法。LIS的变形好像不太多,下面是两个很相似的双向LIS问题,其实第二个题的代码是直接用第一个题的代码改的。uva10543:http://uva.onlinejudge.org/index.php?option=com_onl原创 2014-05-13 17:40:17 · 1060 阅读 · 0 评论 -
Leetcode #32 Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", which原创 2015-08-14 12:50:45 · 394 阅读 · 0 评论