当前位置:网站首页>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 .
边栏推荐
- 【leetcode天梯】链表 · 022 链表中倒数第k个节点
- Alibaba最新神作!耗时187天肝出来1015页分布式全栈手册太香了
- FPGA flash reading and writing based on SPI
- Implementation of SPI communication protocol based on FPGA
- 什么是堆栈以及堆栈的区别
- 去中心化存储面临的挑战
- [C language] program environment and preprocessing
- Know two things: how does redis realize inventory deduction and prevent oversold?
- Weights & Biases (一)
- How can win11 add 3D effects to pictures? Win11 method of adding picture 3D effect
猜你喜欢
![二叉树高度 [log2n]+1与log2(n+1)是否相等](/img/64/381376190218d5b2cdfd8b1197e8f6.png)
二叉树高度 [log2n]+1与log2(n+1)是否相等

What is stack and the difference between stacks

Access intranet rds+mysql through SSH

canvas绘制文本和清除绘制
![[shutter -- layout] linear layout (row and column)](/img/0e/df0f4bce73dd9785cc843adaf371d0.png)
[shutter -- layout] linear layout (row and column)

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

FPGA实现IIC协议(一)IIC总线协议

(CVPR-2022)BiCnet

How can win11 add 3D effects to pictures? Win11 method of adding picture 3D effect

Elk note 25 - expérience rapide APM
随机推荐
FPGA基于spi的flash读写
ES6其他语法及扩展语法总结
有向图之求两点之间所有路径
一、爬虫概念及基本流程
It's too strong. An annotation handles the data desensitization returned by the interface
看完这篇,彻底搞懂 gRPC!
[shutter -- layout] flexible layout (flex and expanded)
[paper reading] gettext: trajectory flow map enhanced transformer for next POI recommendation
ZigBee集成开发环境IAR安装
not all arguments converted during string formatting
H7-TOOL的I2C接口方式脱机烧录操作方法,已经发布(2022-07-16)
数据链路层 -------- 以太网 和 ARP
Alibaba最新神作!耗时187天肝出来1015页分布式全栈手册太香了
SQL 语句练习
.Net CLR R2R编译的原理简析
Emgucv common function function description "suggestions collection"
识别引擎ocropy->ocropy2->OCRopus3总结
Weights & biases (I)
Lendingclub loan status business details current, charge off, issued, full paid, grace period
Brief introduction of Perl language