当前位置:网站首页>[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)
边栏推荐
- PHP online confusion encryption tutorial sharing + basically no solution
- XJY-220/43AC220V静态信号继电器
- 冲击继电器ZC-23/DC220V
- Metauniverse and virtual reality (II)
- Error msb8031: building an MFC project for a non Unicode character set is deprecated
- 第53章 从业务逻辑实现角度整体性理解程序
- Experiment 8 T-SQL, stored procedure
- The longest selling mobile phone in China has been selling well since its launch, crushing iphone12
- Oracle临时表详解
- Training discipline principle of robot programming
猜你喜欢

Oracle table creation and management

What if the disk of datanode is full?

PHP online confusion encryption tutorial sharing + basically no solution

C # Generate PPK files in Putty format (passthrough support)

初识 Flutter 的绘图组件 — CustomPaint
![分割链表[先取next再斩断链表防止断链]](/img/eb/708ab20c13df75f4dbd2d6461d3602.png)
分割链表[先取next再斩断链表防止断链]

Practical shell knowledge

集群与LVS介绍及原理解析

K210工地安全帽

DLS-42/6-4 DC110V双位置继电器
随机推荐
解析融合学科本质的创客教育路径
Service
mustache语法
C # generates PPK files in putty format (supports passphrase)
Training discipline principle of robot programming
Two-stage RO: part 1
ArrayList分析1-循环、扩容、版本
Oracle临时表详解
Oracle data integrity
软硬件基础知识学习--小日记(1)
DX-11Q信号继电器
Problem solving: how to manage thread_local pointer variables
The longest selling mobile phone in China has been selling well since its launch, crushing iphone12
Authentication principle of Ranger plug-in
第53章 从业务逻辑实现角度整体性理解程序
K210门禁毕设
Chapter 53 overall understanding of procedures from the perspective of business logic implementation
Flutter Error: Cannot run with sound null safety, because the following dependencies don‘t support
给按钮的边框和文字设置不同的背景色
ESP8266 RC522