
dp
文章平均质量分 86
StevenIsSnail
辛苦理所当然。年轻就拼搏。挑战不确定。
展开
-
【hihode chanllenge 5】
解答=========C 与链原创 2014-11-13 00:50:40 · 618 阅读 · 0 评论 -
资格赛
1 算日期,wa很奇怪 #includetypedef long long int LL;#include #include#include "assert.h"using namespace std;char a[200],b[200],c[200], s[200];LL func(LL a, LL b, int k){ LL a1 = (a+k-1)/k;原创 2015-04-18 01:30:37 · 693 阅读 · 0 评论 -
微软实习招聘题目: recruiment
x男, y女, 工资、 能力最大值, 最小序列#include #include#include #include using namespace std;#include int main(){ int ms,x, y,n; cin>>n>>x>>y>>ms;cin.get(); vector s(n, 0); vector b(n, 0); ve原创 2015-04-03 21:52:42 · 682 阅读 · 0 评论 -
【树递归】找包含节点0共M个节点的最大(权)连通子树||找最长直径
#include#include using namespace std;void dfs(vector > &edges,vector > &tree,int p,int n){ for(int i=0;i<edges[n].size();i++){ int j=edges[n][i]; if(p==j) continue; tree[n].push_back(原创 2014-09-21 00:31:37 · 878 阅读 · 0 评论 -
【矩阵二维或三维dp】最大子矩阵,子矩阵快速求和(用到最大直方图)
Maximal Rectangle Total Accepted: 9039 Total Submissions: 41503My SubmissionsGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return i原创 2014-08-02 17:46:47 · 1178 阅读 · 0 评论 -
【gcj 2008 1c】长数字串运算计数,递增子序列计数
第二题 长数字串运算计数长度为D的数字串(D两次DP 第一次用于区间[l, r] 对应的大整数对小整数 求余(见数字分类下的某篇文章)。 第二次是区间分解dp。算法code: https://github.com/stevenberge/acm/blob/master/gcj/20081c2.cc第三题 递增子序列计数 给定一个数列,求严格的单增子序原创 2014-12-14 18:58:12 · 675 阅读 · 0 评论 -
【树dp】 缩地(d步内最大权值)
这个题目的地推方程优良种原创 2014-10-05 15:18:45 · 758 阅读 · 0 评论 -
【树dp+状态机背包】 自驾旅行III 找最小权路径
递推方程:原创 2014-10-05 23:43:59 · 1013 阅读 · 2 评论 -
【树形dp】Binary Tree Maximum Path Sum
Binary Tree Maximum Path Sum Total Accepted: 14936 Total Submissions: 75024My SubmissionsGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tr原创 2014-08-01 22:59:16 · 874 阅读 · 0 评论 -
【一维动规】 regular string 正则匹配、Word Break II
Regular Expression Matching Total Accepted: 13504 Total Submissions: 67886My SubmissionsImplement regular expression matching with support for '.' and '*'.'.' Matches any single charac原创 2014-08-01 22:09:02 · 808 阅读 · 1 评论 -
【二维dp_右下递推】interleaving、Distinct Subsequences、字符串交错、min edit distance、longest common sequence(LCS)
class Solution {public: bool isInterleave(string s1, string s2, string s3) { int n=s1.length(),m=s2.length(); if(n+m!=s3.length()) return false;///@@@error: s3.length can be not q原创 2014-08-01 23:24:16 · 583 阅读 · 0 评论 -
【编程之美】初赛2015 待填坑
题目1 : 彩色的树时间限制:2000ms单点时限:1000ms内存限制:256MB描述给定一棵n个节点的树,节点编号为1, 2, …, n。树中有n - 1条边,任意两个节点间恰好有一条路径。这是一棵彩色的树,每个节点恰好可以染一种颜色。初始时,所有节点的颜色都为0。现在需要实现两种操作:1. 改变节点x的颜色为y;2. 询问整转载 2015-05-11 00:51:49 · 1644 阅读 · 0 评论