【HDOJ】4029 Distinct Sub-matrix】的更多相关文章

思路是枚举矩阵列数,然后将字符矩阵转换成字符串,通过字符数组求不同子串数目.最后,减去不成立的情况.使用特殊字符分割可能的组合. /* 4029 */ #include <iostream> #include <sstream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vec…
title: [线性代数]2-4:矩阵操作(Matrix Operations) toc: true categories: Mathematic Linear Algebra date: 2017-09-05 17:15:19 keywords: addition subtraction multiplication inner product outer product Abstract: 矩阵基本计算,包括加减乘法,主要是乘法的几种不同的理解 Keywords: Addition,Subt…
简单DP. /* 2830 */ #include <iostream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <algorithm> #include <cstdio> #include <cmath> #i…
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到boundry,使得boundry * n_edge - sum_edge <= k/b, 或者建立s->t,然后不断extend s->t. /* 4729 */ #include <iostream> #include <sstream> #include <…
题目: Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relat…
Search a 2D Matrix Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer…
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous ro…
DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define rep(i,n) for(int i=0;i<n;++i) #define…
DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[k+1][j-(k-i+1)]+w(i,k,j)} (这个地方一开始写错了……) 即,将一棵树从k处断开成(i,k)和(k+1,i+j-1)两棵树,再加上将两棵树连起来的两条树枝的长度w(i,k,j) 其中,$ w(i,k,j)=x[k+1]-x[i]+y[k]-y[i+j-1] $ 那么根据四边形…
DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明显可以减小极差 然后……直接四边形不等式上吧……这应该不用证明了吧? MLE了一次:这次的w函数不能再开数组去存了……会爆的,直接算就行了= =反正是知道下标直接就能乘出来. 数据比较弱,我没开long long保存中间结果居然也没爆……(只保证最后结果不会爆int,没说DP过程中不会……) //H…