
DP
mizp
这个作者很懒,什么都没留下…
展开
-
2020牛客暑期多校训练营(第七场)
题目链接A - Social Distancing题意:思路:C - A National Pandemic题意:思路:I - Valuable Forests题意:思路:J - Pointer Analysis题意:思路:原创 2020-09-02 15:32:48 · 370 阅读 · 0 评论 -
2020牛客暑期多校训练营(第九场)
题目链接B - Groundhog and Apple Tree题意:思路:E - Groundhog Chasing Death题意:思路:J - The Escape Plan of Groundhog题意:思路:原创 2020-08-31 23:49:09 · 188 阅读 · 0 评论 -
Xenon's Attack on the Gangs Codeforces Round #614 (Div. 2)
Xenon’s Attack on the Gangs题意: 给你一棵树,将0~n-2一一赋值给n-1条边,则S最大可能取值S=∑1≤u<v≤nmex(u,v)S=\sum_{1\le u< v\le n}mex(u,v)S=∑1≤u<v≤nmex(u,v)mex(u,v)表示u到v的路径中未出现的最小非负数思路: 这里推荐一个视频题解,个人觉得讲得非常好 qscqes...原创 2020-01-22 17:07:15 · 457 阅读 · 0 评论 -
ABBA 2019牛客暑期多校训练营(第一场)
题目链接: https://ac.nowcoder.com/acm/contest/881/E题目:Bobo has a string of length 2(n + m) which consists of characters A and B. The string also has a fascinating property: it can be decomposed into (n ...原创 2019-07-20 09:37:00 · 181 阅读 · 0 评论 -
PACM Team (多种重量的01背包+记录路径) 牛客
题面:Since then on, Eddy found that physics is actually the most important thing in the contest. Thus, he wants to form a team to guide the following contestants to conquer the PACM contests(PACM is sh...原创 2019-07-24 18:54:09 · 281 阅读 · 0 评论 -
F1. Short Colorful Strip Codeforces Global Round 4 (区间dp)
链接: http://codeforces.com/contest/1178/problem/F1题面:There are n+1 distinct colours in the universe, numbered 0 through n. There is a strip of paper m centimetres long initially painted with colour 0...原创 2019-07-22 21:03:04 · 419 阅读 · 0 评论 -
Yet Another Subarray Problem Codeforces Round 69 dp
链接: http://codeforces.com/contest/1197/problem/D题面:You are given an array a1,a2,…,an and two integers m and k.You can choose some subarray al,al+1,…,ar−1,ar.The cost of subarray al,al+1,…,ar−1,ar ...原创 2019-07-23 12:48:11 · 201 阅读 · 0 评论 -
Rectangle Painting 1 Codeforces Round #576 (Div. 2)
链接: https://codeforces.com/contest/1199/problem/F题面:There is a square grid of size n×n. Some cells are colored in black, all others are colored in white. In one operation you can select some rectang...原创 2019-08-06 19:29:29 · 305 阅读 · 0 评论 -
Treasure Hunting Codeforces Round #577 (Div. 2)
链接: https://codeforces.com/contest/1201/problem/D题面:You are on the island which can be represented as a n×m table. The rows are numbered from 1 to n and the columns are numbered from 1 to m. There a...原创 2019-08-06 20:01:50 · 393 阅读 · 0 评论 -
筱玛爱阅读 (状压+子集dp) 牛客
链接: https://ac.nowcoder.com/acm/contest/946/B题面:筱玛是一个热爱阅读的好筱玛,他最喜欢的事情就是去书店买书啦!一天,他来到一家有nn本书的书店,筱玛十分快乐,决定把这家店里所有的书全部买下来。正巧今天店里在搞促销活动,包含若干个促销方案。每个促销方案是由指定的若干本书构成的集合,如果购买了该方案中所有的书,那么其中最便宜的一本书将免费。但是,每...原创 2019-08-09 18:59:41 · 276 阅读 · 0 评论 -
符文能量 dp Comet OJ
链接: https://cometoj.com/contest/58/problem/C?problem_id=2760题意:n个二元组(ai,bi)(a_{i},b_{i})(ai,bi),相邻的可以合并成一个新的二元组(ai,bi+1)(a_{i},b_{i+1})(ai,bi+1)。每次合并会释放出ai+1∗bia_{i+1}*b_{i}ai+1∗bi的能量,你可以把原本的一...原创 2019-08-10 08:35:36 · 226 阅读 · 0 评论 -
DongDong跳一跳 DP+权值线段树优化 牛客
链接:https://ac.nowcoder.com/acm/contest/904/C题面:DongDong有一只超可爱的英短喜欢跳一跳,但此跳一跳非彼跳一跳有n根柱子,每根柱子都有一个高度和柱子上面鱼干的数量,英短开始的时候可以选择站在任意一根柱子上,每次跳跃不限长度而且只能从左向右跳跃,但只能跳到高度与当前所站高度差绝对值小于等于m的柱子上,英短可贪心了,想吃最多的鱼干,请你设计一个程...原创 2019-08-22 14:30:48 · 245 阅读 · 0 评论 -
Removal dp(牛客)
题意: 给你一组数,数最大不超过10,问你删去m个数形成新的序列有多少种?思路: dp[i][j],i为长度,j为第i位的当前数字的方案数,sum[i]为长度为i时的方案数,答案就是sum[n−m]dp[i][j],i为长度,j为第i位的当前数字的方案数,sum[i]为长度为i时的方案数,答案就是sum[n-m]dp[i][j],i为长度,j为第i位的当前数字的方案数,sum[i]为长度为i时的...原创 2019-07-09 21:29:03 · 181 阅读 · 0 评论 -
Symmetric Matrix (dp递推)牛客
题意: 问我们一个n*n沿对角线对称的矩阵有多少个,且每行之和为2该题我们需要转换一下思想,把此图看成一张图的邻接矩阵,这张图因为当i==j时,a[ i ] [ j ]=0,故不存在自环,且每行和为2,也就是说每个点都有两条边连接着,a[ i ][ j ]=2,意味着存在重边,也就是说两点成环,这张图就是存在许多环,问你多少种成环情况?思路: 把问题转化成这个角度就更好想了,设dp[ n ]...原创 2019-06-16 19:11:14 · 379 阅读 · 0 评论 -
Surf (dp)
题目: 给出一系列事件的起始时间,每件事情的贡献值,以及花费的时间,问怎样才能得到最大的贡献值思路: dp,ennnn看到dp就不会,我好菜啊,dp[i]表示时间线,#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=3e5+5;const int M=1e6+5;ll ...原创 2019-03-29 18:13:54 · 187 阅读 · 0 评论 -
Max Sum Plus Plus---hdu1024(动态规划求M段的最大和)
题目链接: https://vjudge.net/contest/68966#problem/A题意: 求n个数中m段不相交子序列的最大和思路: 因为受到空间内存限制,而且当前状态只受上一状态影响,用滚动数组优化。#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1e6+5...原创 2019-04-26 13:01:33 · 194 阅读 · 0 评论 -
FatMouse and Cheese HDU - 1078
题目链接: https://vjudge.net/contest/68966#problem/P题面:FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0...原创 2019-05-02 14:46:41 · 189 阅读 · 0 评论 -
Doing Homework HDU - 1074(状压dp)
链接: https://vjudge.net/contest/68966#problem/D题意: 给你N门课程的期限与完成每门课程所需要的时间,若超出期限时,每超过一天就扣一分,问最少扣多少分,并输出完成顺序以后看到这种N<30时极大可能是状压思路: (因为N<=15),所以可以用状压,接着需要最小字典序,因为题目所给课程已经按最小字典序输入,而且我们是从小dp到大,注意储存就...原创 2019-04-28 15:57:02 · 166 阅读 · 0 评论 -
Super Jumping! Jumping! Jumping! (HDU - 1087)
链接: https://vjudge.net/contest/68966#problem/E题意: 从起点跳到终点,要求跳到每个点的分数是递增的,求获得最大分数思路: DP,O(n2)O(n^2)O(n2)#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;typedef long long ll...原创 2019-05-01 01:27:06 · 114 阅读 · 0 评论 -
Making the Grade POJ - 3666
题目链接: https://vjudge.net/contest/68966#problem/S题意: 给你一个数组,修改成单调递增或单调递减(非严格),算出修改贡献值,| A 1 - B 1| + | A 2 - B 2| + … + | AN - BN |思路: 修改后的值肯定原数组里面有的数,DP#include<cstdio>#include<cstring&g...原创 2019-05-01 01:32:59 · 218 阅读 · 0 评论 -
Help Jimmy POJ - 1661
题目链接: https://vjudge.net/contest/68966#problem/M题意: 给你一个起点(x,y)(x,y)(x,y)与高度H,与N个高度不一的踏板,问掉下最快的时间是多少,每次掉下去不能超过M米思路: 将高度sort一下,将地面与起点加进去,每个高度的左边与右边进行DP#include<iostream>#include<cstdio>...原创 2019-05-01 01:37:00 · 148 阅读 · 0 评论 -
Phalanx (HDU - 2859) DP
HDU 1078 FatMouse and Cheese (简单DP)Problem DescriptionToday is army day, but the servicemen are busy with the phalanx for the celebration of the 60th anniversary of the PRC. A phalanx is a...原创 2019-05-01 16:52:01 · 174 阅读 · 0 评论 -
免费馅饼 HDU - 1176
题意: 假设在接下来的一段时间里,馅饼都掉落在0-10这11个位置。开始时gameboy站在5这个位置,因此在第一秒,他只能接到4,5,6这三个位置中其中一个位置上的馅饼。问gameboy最多可能接到多少个馅饼?(假设他的背包可以容纳无穷多个馅饼)思路: dp[ i ][ j ]表示在i秒j位置接到最大的馅饼量#include<bits/stdc++.h>using namesp...原创 2019-05-19 19:08:27 · 188 阅读 · 0 评论 -
kuangbin专题 概率/期望DP总结
题目链接: https://vjudge.net/contest/76505#overviewA- A Dangerous Maze LightOJ - 1027题意:现在在你面前有N个门。每个门要么把你传送出迷宫,要么把你传送来的位置且你的记忆也会回到初始的时候。现在给出每个门传送的时间t,若t为正数,说明该门花费时间t可以将你传送出迷宫,若 t 为负数,说明该门花费时间 t 将你传送...原创 2019-05-26 21:52:12 · 462 阅读 · 0 评论 -
Spring Training IV D (dp)
题目链接: http://codeforces.com/group/NVaJtLaLjS/contest/240951/problem/DMashmokh and ACM题意: 给定n与k,给组成一个长度k的序列且a[i]总能被a[i+1]整除,元素范围0<a[i]<=n,问有多少种组合?思路: 训练期间手推了好久都想不到是dp,我好菜啊,看着一群大佬过了,我还在暴力手推我们...原创 2019-03-20 22:35:51 · 100 阅读 · 0 评论