当前位置:网站首页>[learning notes] simple DP
[learning notes] simple DP
2022-07-01 01:14:00 【Ants looking up at the starry sky】
It may not be simple
thank C202044zxy The courseware and wonderful explanation prepared by the senior students .
Treatment plan
- Be careful dp Dimensional consciousness of
- We instinctively take time as the dimension dp , However, it is difficult to continue
- Start from the dimension of planning prefix , d p i dp_i dpi It means that you will [ 1 , r i ] [1,r_i] [1,ri] The minimum cost of a total cure
- We instinctively press r i r_i ri Sort , about j < i j<i j<i The situation of , according to T i < T j T_i<T_j Ti<Tj and T i > T j T_i>T_j Ti>Tj Classification discussion can get a very reasonable transfer formula :
- d p i = d p j + c i ( r j − l i + 1 ≥ ∣ T i − T j ∣ ) dp_i=dp_j+c_i(r_j-l_i+1\geq |T_i-T_j|) dpi=dpj+ci(rj−li+1≥∣Ti−Tj∣)
- such O ( n 2 ) O(n^2) O(n2) Of d p dp dp You'll get 0pts Good result !
- The reason is that we don't realize j > i j>i j>i Time can also be transferred , Draw a picture to show that the transfer mode is rather the same
- therefore dp The stage is not obvious , Because there may be a curve to save the country ( Time is influencing )
- Analyze the special properties of the transfer equation , Think of the shortest path optimization ( Remove the absolute value trick Don't say )
- Time complexity O(mlogm) ( Praise for the author !)
Lanterns
This question is also difficult- This problem is difficult in state design
I know the routine ! - The most basic state is d p i , j dp_{i,j} dpi,j Indicates that the processing is finished [ 1 , i ] [1,i] [1,i] The longest prefix after the lantern of is j j j Is it feasible
- So the number of States O ( n 2 ) O(n^2) O(n2)
- The problem is that we don't realize dp Values can also be used to describe dimensions
- set up d p i dp_i dpi Indicates that the processing is finished [ 1 , i ] [1,i] [1,i] The longest prefix that can be covered after the lantern
- Then there is the classified discussion . Just pay attention to the sub problem .( Cuckoo
Favorite Game
- It's really simple dp , however cf score 3300 It must not be simple
- This question involves many dimensions , But experienced oier
Excluding meCan write basic dp - d p [ S ] [ i ] [ j ] dp[S][i][j] dp[S][i][j] Indicates that the set passing through the portal is S , Currently in place i , Did j Minimum time for tasks
- This looks stupid dp It actually contains all dimensions , Time complexity 2 14 × 10 0 3 2^{14}\times 100^3 214×1003
- If at the portal , Do not care about location , If in the landmark , Don't care about time
- This enlightens us on dp Dimension reduction
- set up f[S][i] Indicates that you are currently at the portal , complete i Minimum time for tasks ,g[S][i] It's on the second day i Landmarks , Maximum number of tasks completed .
- We can give a similar classification discussion to dp Dimension reduction . Time complexity 2 14 × 10 0 2 2^{14}\times 100^2 214×1002
Group Projects
- This question is really not difficult
But I really stuck for a long time - The simple way is ,dp[i][j][k] Before presentation i Number , Yes j Group has no maximum value , The minimum sum is k Number of alternatives
- So the number of States O ( n 3 m ) O(n^3m) O(n3m)
In situ explosion - Would you rather think of using k ≤ 1000 k\leq 1000 k≤1000 To optimize
- But rather, my approach k Will be far more than the given 1000
- It is also appropriate to be robbed , Even a little dp Skills have not accumulated to
- We assume that a[i] Is the current maximum , Calculate the sum of disharmony at this time , This dimension satisfies <=1000
- Number of final states O ( n 2 m ) O(n^2m) O(n2m)
边栏推荐
猜你喜欢

How to do the performance pressure test of "Health Code"

P4学习——Basic Tunneling

Principes de formation de la programmation robotique

Oracle临时表详解

Left join displays the specified value when the left join matching data is null

Exercises on recursion in C language

Date类的实现

闭锁继电器YDB-100、100V

二十多年来第一次!CVPR最佳学生论文授予中国高校学生!

Oracle table creation and management
随机推荐
leetcode 474. Ones and zeroes (medium)
CMU15445 (Fall 2019) 之 Project#1 - Buffer Pool 详解
ArrayList分析1-循环、扩容、版本
魔王冷饭||#101 魔王解惑数量多与质量;员工管理;高考志愿填报;游戏架构设计
2022就要过去一半了,挣钱好难
【日常记录】——对BigDecimal除法运算时遇到的Bug
Oracle临时表详解
Two-stage RO: part 1
人穷志不短,穷学生也能玩转树莓派
Tibetan poem PTA
Length of the longest integrable subarray
Day31-t1380-2022-02-15-not answer by yourself
PyTorch安装并使用gpu加速
分割链表[先取next再斩断链表防止断链]
Oracle table creation and management
How to scroll uitableview to a specific position - how to scroll uitableview to specific position
CMU15445 (Fall 2019) 之 Project#1 - Buffer Pool 详解
pytorch编程知识(2)
High quality pump SolidWorks model material recommended, not to be missed
深度学习的历史