当前位置:网站首页>Summarize some recent tricks
Summarize some recent tricks
2022-07-23 19:25:00 【lovesickman】
Summarize some recently seen TRICK:
Union checking set O ( n + m ) O(n+m) O(n+m) Solve the problem of interval merging 3115. Crazy steamed bread .
Slide the window enumeration to i i i Time to time [ i − k , i − j ] [i-k,i-j] [i−k,i−j] The highest value in .
Monotone stack needs to reverse the order to find the rightmost value closest to itself .
Enumeration matrix has 4 A degree of freedom , By enumerating the upper and lower boundaries, the matrix can be changed into 1 Dimensional , It is being realized with binary or double pointers O ( n 3 ) O(n^3) O(n3) Traverse .
Given a n ∗ m n*m n∗m Matrix Ask for one c ∗ c c*c c∗c The maximum value in the submatrix of size . It can be realized by two-dimensional sliding window . The core idea is to regard two dimensions as one dimension . First, find a length of c c c Sliding window of , Find a length of c c c Sliding window of , Finally, enumerate the answers .
DP The essence of is combinatorics , Can pass 0/1 knapsack , The idea of complete knapsack deduces the combinatorial number formula and the resettable combinatorial formula in combinatorics .
Remember some smart data for interval merging , Interval merging can O ( n ) O(n) O(n) Realization , The left endpoint is sorted from small to large .
unorder_map, capitation O ( 1 ) , The worst O ( n ) O(1), The worst O(n) O(1), The worst O(n) , Fast platoon is shared equally O ( n l o g n ) , The worst O ( n 2 ) O(nlogn), The worst O(n^2) O(nlogn), The worst O(n2) You can prevent being stuck by initializing the size ,(CF With the exception of , need mt19937)
Interval merging has 3 Methods , Union checking set , greedy , discretization + Difference .
Brush table method can solve knapsack problem K K K Excellent solution .
Given a matrix , Find the area of the largest submatrix with constraints , Or consider each line separately , run n n n Time Monotonic stack .
Dye a pile of things for the final color , You can think backwards .
Many ideas for solving problems on trees come from The center of gravity of the tree also The diameter of the tree .
Many problems need to be gradually decomposed , If there is no thought , You can try , Draw pictures to find rules and properties , Two point answer turns to judgment , etc.
Double pointer key ( In fact, if you write too much, there is nothing critical ), Definition j = f [ i ] j = f[i] j=f[i] , If i i i After determining , j j j Only monotonously left ( Not seen )/ Move right , You can directly double pointer .while Inside the loop is the negative condition .
Find the maximum value on the matrix except for n n n The monotone queue can also be two-dimensional S T ST ST surface .
Line segment tree pointer writing ,new Super slow , You can define static nodes and move them by one bit .
L C A LCA LCA Yes t a r j a n tarjan tarjan , Union checking set , Multiply Three ways of writing , At least recite one .
If two intervals [ l 1 , R 1 ] , [ R 1 + 1 , R 2 ] [l_1,R_1],[R_1+1,R_2] [l1,R1],[R1+1,R2] Want more space , You can subscript by 2.
somewhat sbTwo dimensional and one-dimensional can be transferred into one dimension of two-dimensional array , But what if you follow the column ? Or rewrite a , Or take out the data first according to the column , Then pass it in .
Sometimes I put DP The state is too dead , Then it is found that the state transition equation cannot be written at all , You can take a step back , Give Way DP Multi band one-dimensional information , Try again. . such as , Definitely , Definitely not .
The feasibility of DP, It can be used bitset Pretend to realize .
Some known middle order traversals and xx Traverse , Output bfs Preface question , stay dfs Wear a layer inside , Can directly record bfs order .
Cartesian tree .
边栏推荐
- Elk notes 25 - experience APM quickly
- Emgucv common function function description "suggestions collection"
- Shell
- C # startup program loses double quotation marks for parameters passed. How to solve it?
- moxa串口服务器型号,moxa串口服务器产品配置说明
- .NET Core 实现后台任务(定时任务)Longbow.Tasks 组件(三)
- 单调队列优化DP
- Design of UART interface based on FPGA
- 当代励志“女”录
- H7-TOOL的I2C接口方式脱机烧录操作方法,已经发布(2022-07-16)
猜你喜欢

How can win11 add 3D effects to pictures? Win11 method of adding picture 3D effect
.NET Core 实现后台任务(定时任务)Longbow.Tasks 组件(三)

Little fish sends lidar | just dinner is the first lottery

【leetcode天梯】链表 · 022 链表中倒数第k个节点

多线程与高并发day11

入门数据库days2

Still using xshell? You are out. I recommend a more modern terminal connection tool

@JPA annotation in entity

有向图之求两点之间所有路径

Mee | Zhejiang University Chenglei group develops a new method for designing and constructing synthetic flora
随机推荐
数据链路层 -------- 以太网 和 ARP
入门数据库Days3
H7-TOOL的CANFD/CAN接口脱机烧写操作说明, 已经更新(2022-07-12)
FPGA实现IIC协议(一)IIC总线协议
总结一些最近见到的 TRICK
LeetCode刷题:回文数
DevStack云计算平台快速搭建
多线程&高并发(全网最新:面试题+导图+笔记)面试手稳心不慌
.NET Core 实现后台任务(定时任务)Longbow.Tasks 组件(三)
Alibaba's latest masterpiece! It took 187 days for the liver to come out. 1015 pages of distributed full stack manuals are so delicious
mysql的访问端口是什么意思_数据库端口是什么端口号
国外芯片,为什么有中文资料和网页?
You must execute multiple requests and catch errors. Using try catch is not elegant
Little fish sends lidar | just dinner is the first lottery
Four principles of interface design
Detailed explanation of TCL scripting language (1)
[Nuxt 3] (九)服务器路由
SQL 语句练习
.NET Core 实现后台任务(定时任务)Longbow.Tasks 组件(三)
LeetCode每日一题(1514. Path with Maximum Probability)