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 …

Luogu-P4755 Beautiful Pair Read More »

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 …

ABC209F Deforestation Read More »

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 …

CSP-J 2022 Travel Notes Read More »

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 …

CF-1385E Directing Edges Read More »

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 …

Topological Sort Notes Read More »

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 …

Bit operation notes Read More »

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 …

Luogu-P1776 Treasure Screening Read More »

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 …

Segment tree merge notes Read More »

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 Read More »

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 Read More »