totaled
totaled
全部文章
leetcode
atcoder(1)
codeforces(6)
Linux(5)
操作系统(2)
数据结构(7)
未归档(1)
算法(23)
网络编程(1)
计算机网络(5)
题解(84)
归档
标签
去牛客网
登录
/
注册
qin_peng
O_O
全部文章
/ leetcode
(共10篇)
leetcode.5407. 切披萨的方案数(dp)
5407. 切披萨的方案数 设dp[i][j][k]为矩形(i,j),(n,m)内切割了k次的方案数,然后倒推就行。 class Solution { public: int dp[55][55][15]; int sum[55][55]={0}; const int m...
dp
2020-05-10
0
956
leetcode.5387. n个匹配方案数(状压dp)
5387. 每个人戴不同帽子的方案数 设表示前个帽子状态为的合法方案数,表示里这些人是否戴了帽子的集合。那么对于第个帽子,要么只有一个人戴,要么没有人戴。 所以对于合法的第个人戴这个帽子或者没有人戴。 没有人戴这个帽子。 合法的第个人戴这个帽子。 复杂度 class Solution { p...
dp
2020-05-03
0
1137
leetcode.943. 最短超级串(dp,TSP)
943. 最短超级串 每两个字符串连边,边的长度等价于这两个字符串的重和长度,问题:就是要求一条简单路径走过所有的点,并且长度最长。设表示第个点到集合的最长路径,表示这个集合内的点的 。所以转移就是 ,从小到大。 class Solution { public: bool equ(...
dp
2020-04-20
0
813
leetcode.5391. 生成数组
5391. 生成数组 设 表示 数组的第 位 最大值是且比较次数是 的方法数那么其中一个就是 第位,最大值在且比较次数是 ,即转移过来的。还有一种情况是第位的最大值也是,那么第位可以选择的数字肯定是 ,所以转移的方程是 所以 const mod int64 = 1000000007 fun...
dp
2020-04-19
0
748
leetcode.5375. 恢复数组
5375. 恢复数组 简单递推 const mod int = 1000000007 func numberOfArrays(s string, m int) int { n:=len(s) var dp [100005]int dp[0]=1 for i:=1...
dp
2020-04-19
0
757
leetcode.1406. 石子游戏 III
1406. 石子游戏 III 设代表该玩家在区间内的最大值,那么一定是等于减去上一个玩家在区间的最小值上一个玩家可能取了一个,两个或者三个。所以可以有,; class Solution { public: int dp[50005]; string stoneGameIII(v...
dp
2020-04-11
1
938
leetcode.1326. 灌溉花园的最少水龙头数目(思维,dp)
1326. 灌溉花园的最少水龙头数目 同 codeforces 1175 E. Minimal Segment Cover class Solution { public: int minTaps(int n, vector<int>& a) { ...
dp
2020-02-10
0
866
leetcode.1335. 工作计划的最低难度(dp)
1335. 工作计划的最低难度 。 。 class Solution { public: int MAX[305][305]; int dp[15][305]; int minDifficulty(vector<int>& job, int d...
dp
2020-02-10
0
838
leetcode.1344. 跳跃游戏 V(搜索,dp)
1344. 跳跃游戏 V 记忆化搜索即可。 class Solution { public: vector<int>g[1024]; int dp[1003]; int dep=0; void dfs(int u,int pos){ ...
dp
2020-02-10
0
716
leetcode.1349. 参加考试的最大学生数(状压dp)
1349. 参加考试的最大学生数 状态压缩。将每一行的学生的状态看作,表示第行状态为时前行的最大学生数量。状态转移方程:。。 class Solution { public: int maxStudents(vector<vector<char>>&...
dp
2020-02-10
0
982