当前位置:网站首页>[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)
边栏推荐
- 二十多年来第一次!CVPR最佳学生论文授予中国高校学生!
- 蒹葭苍苍,白露为霜。
- K210门禁毕设
- 什么是产品思维
- 2021电赛F题openmv和K210调用openmv api巡线,完全开源。
- Koa koa-combine-routers 分路由管理
- New content violation degree determination scana bad information monitoring capability update issue 5
- ArrayList analysis 1-cycle, capacity expansion, version
- Mindjet mindmanager2022 mind map decompression installer tutorial
- 写给 5000 粉丝的一封信!
猜你喜欢

Analysis of blocktoken principle

Sword finger offer 19 Regular Expression Matching

ORB-SLAM2源码学习(二)地图初始化

人穷志不短,穷学生也能玩转树莓派

The longest selling mobile phone in China has been selling well since its launch, crushing iphone12

C#生成putty格式的ppk文件(支持passphrase)
![[original] PLSQL index sorting optimization](/img/91/dcd0262705a19645f1a87d4cf03bc8.jpg)
[original] PLSQL index sorting optimization

【日常记录】——对BigDecimal除法运算时遇到的Bug

Exercises on recursion in C language

5. TPM module initialization
随机推荐
The quantity and quality of the devil's cold rice 101; Employee management; College entrance examination voluntary filling; Game architecture design
Practical shell knowledge
P4学习——p4runtime
XJY-220/43AC220V静态信号继电器
什么是产品思维
【网络丢包,网络延迟?这款神器帮你搞定所有!】
Training discipline principle of robot programming
[LeetCode] 爬楼梯【70】
K210工地安全帽
A single element in an ordered array
Vnctf 2022 cm CM1 re reproduction
The question of IBL precomputation is finally solved
Sword finger offer 18 Delete the node of the linked list
pytorch编程知识(2)
06.论Redis持久化的几种方式
New content violation degree determination scana bad information monitoring capability update issue 5
Day31-t1380-2022-02-15-not answer by yourself
CSDN common complex formula template record
High quality pump SolidWorks model material recommended, not to be missed
Win11安装redis 数据库以及redis desktop manager的下载