# ChungZH 的小窝

## Luogu-P4755 Beautiful Pair

Original link: https://blog.chungzh.cn/articles/luogu-p4755/ Luogu-P4755 Beautiful Pair Title meaning Small D has a sequence \${a}\$, when a number pair \$(i,j)\$ (\$i \le j\$) satisfies the product of \$a_i\$ and \$a_j\$ is not greater than \$a_i, a_{i+1 }, \ldots, a_j\$, Little D thinks this pair is beautiful. Please find the number of beautiful pairs. \$1\le n\le{10}^5\$, \$1\le […]

## ABC209F Deforestation

Original link: https://blog.chungzh.cn/articles/abc-209f/ ABC209F Deforestation The meaning of the question: Given the height of \$n\$ trees, the cost of cutting the \$i\$th tree is \$h_i+h_{i-1}+h_{i+1}\$, how many schemes can be cut down? The total cost of all trees is the smallest. The cost of cutting down a tree is only related to the height of

## CF-342E Xenia and Tree – Radical Divide and Conquer

Original link: https://blog.chungzh.cn/articles/cf-342e/ CF342E Xenia and Tree meaning of the title Given a tree of \$n\$ nodes, initially node 1 is red and the rest are blue. The following operations are required to be supported: Turn a node red. Ask the distance of node \$u\$ to the nearest red node. A total of \$q\$ operations.

## CSP-J 2022 Travel Notes

Original link: https://blog.chungzh.cn/articles/csp2022/ preliminary round This time, like in the first year of junior high, I took the exam at my own school, which was comfortable. I feel that the topic is simple, but there are many strange topics. . . (The dalao on the Internet says there are a lot of mistakes? It is

## CF-1385E Directing Edges

Original link: https://blog.chungzh.cn/articles/cf-1385e/ CF-1385E Directing Edges meaning of the title Given a graph consisting of directed and undirected edges, you now need to turn all undirected edges into directed edges such that the resulting graph has no cycles . If it can be done, please output the figure, otherwise output “NO” directly. analyze We first

## Topological Sort Notes

Original link: https://blog.chungzh.cn/articles/topo-sort/ introduce Given a directed acyclic graph (DAG, Directed Acyclic Graph), sort its vertices such that for each directed edge \$(u, v)\$ from \$u\$ to \$v\$, \$u\$ Both come before \$v\$ in the sort. This sort is called topological sorting. Topological sorting is possible if and only if there are no directed cycles

## Bit operation notes

Original link: https://blog.chungzh.cn/articles/bit-operation/ basic concept Bit (bit, also known as binary digit) refers to a 1-bit binary number (0 or 1), which is the smallest unit of information in a computer. Byte: A byte consists of 8 bits. Skillful use of bit operations can improve the space-time efficiency of our programs. Integer Storage and Operations

## Luogu-P1776 Treasure Screening

Original link: https://blog.chungzh.cn/articles/luogu-p1776/ Luogu-P1776 Treasure Screening meaning of the title Finally, the thousand-year-old problem has been solved. Little FF found the treasure room of the royal family, which was filled with countless valuable treasures. This little FF can make a fortune, quack. But there are too many treasures here, and the collection car of the

## Segment tree merge notes

Original link: https://blog.chungzh.cn/articles/merge-seg-tree/ Pre-knowledge: Dynamic open point line segment tree. Binary tree merge Merging is a recursive process. First merge two binary trees rooted at \$u, v\$: Consider the left subtree If neither \$u nor v\$ has a left subtree, leave it blank; If only \$u\$ has a left subtree, then the left subtree of

## Luogu-P2254 “NOI2005” Magnificent Waltz

Original link: https://blog.chungzh.cn/articles/luogu-p2254/ “NOI2005” Magnificent Waltz meaning of the title Think of the ballroom as a matrix of \$N\$ rows and \$M\$ columns, where some squares are stacked with furniture and others are empty spaces. The piano can slide in the clearing, but it cannot hit the furniture or slide out of the ballroom, otherwise

## Tree Array Notes

Original link: https://blog.chungzh.cn/articles/binary-indexed-tree/ I have learned the line segment tree for a long time, but I am ashamed that the simpler tree-like array has not been deeply understood, and it only stays at the level of memorizing the code. Learn about tree arrays seriously today. introduce Tree arrays (Binary Index Tree, BIT / Fenwick Tree)

## Tree Array Notes

Original link: https://blog.chungzh.cn/articles/binary-indexed-tree/ I have learned the line segment tree for a long time, but I am ashamed that the simpler tree-like array has not been deeply understood, and it only stays at the level of memorizing the code. Learn about tree arrays seriously today. introduce Tree arrays (Binary Index Tree, BIT / Fenwick Tree)

## Luogu-P3521 “POI2011” ROT-Tree Rotations

Original link: https://blog.chungzh.cn/articles/luogu-p3521/ meaning of the title Given a binary tree with n leaf nodes . Each leaf node has a weight \$p_i\$ (note that the root is not a leaf node), and the weights of all leaf nodes constitute a \$1 \sim n\$ permutation. For any node of this binary tree, it is guaranteed