Segment tree + lazy tag + special discretization: Mayor's posters
Title Link: http://poj.org/problem?id=2528
Main idea of the title:
There are n posters to be posted on the wall. The starting position of each poster is given according to the posting order (only the abscissa is considered), and the number of posters that can be seen at last (as long as a little can be seen, it can be seen).
analysis:
...
Posted by jarvishr on Wed, 29 Dec 2021 12:24:45 +0100
LeetCode brushing day 6 (string arrangement)
subject
Give you two strings s1 and s2 and write a function to determine whether s2 contains the arrangement of s1. In other words, one of the permutations of s1 is a substring of s2. Example 1:
Input: s1 = "ab" s2 = "eidbaooo"
Output: true
Explanation: s2 contain s1 One of the permutations of ("ba").
Example 2:
Input: s1= "ab" s2 = ...
Posted by jblack on Wed, 29 Dec 2021 08:45:06 +0100
[C language] dynamic memory distribution
preface
This blog post is only for me to summarize and learn the knowledge of dynamic memory allocation in C language. In the summary process, I refer to many blogs.
Reference blog:
https://www.cnblogs.com/ericling/p/11746972.html
https://blog.csdn.net/MarcoAsensio/article/details/85937002
summary
An array is a collection of a fixed n ...
Posted by CaptainChainsaw on Wed, 29 Dec 2021 04:13:47 +0100
c + + algorithm notes (under update)
algorithm
Sorting algorithm
There are basically eight sorting algorithms
Bubble sortingInsert sortHeap sortSelect sortQuick sortMerge sortCardinality sortShell Sort
Of course, it is not required to fully master all sorting methods. Nevertheless, it is necessary to understand the implementation principle. This provides ideas for us to e ...
Posted by gtal3x on Tue, 28 Dec 2021 23:51:32 +0100
P3246 [HNOI2016] sequence (sum of minimum values of all intervals in query l-r)
In multi calibration, the problem of the sum of the maximum and minimum of all intervals in the query interval l-r is achieved, and many details are not easy to deal with. Looking at the problem solution, it is found that it is a similar original problem, so I intend to supplement the original problem first. Solution: ST Table + monotone stack ...
Posted by gudfry on Tue, 28 Dec 2021 20:49:49 +0100
Heap - find and sort
Question A: large top pile or small top pile?
Title Description
The task queue processed by a CPU is not always processed in chronological order. Some tasks have higher priority. For example, one task needs to schedule the nuclear reactor, and the other task is to print a document. For this task selection and execution scenario that needs t ...
Posted by SargeZT on Tue, 28 Dec 2021 18:03:42 +0100
Segment tree + multiple lazy Tags: maintain sequence
Title Link: https://www.luogu.com.cn/problem/P2023
analysis:
Node of segment tree:
struct Node
{
int l,r;
int add; // Lazy mark addition
int mul; / / lazy mark multiplication
int sum; // Really required value
}
1. How to update sum value through attribute.
, how to update the sum value through add and mul is similar to ...
Posted by amcgrath on Tue, 28 Dec 2021 14:42:15 +0100
Huffman tree sorting
Huffman coding
Huffman coding is mainly used in information compression. It is a coding method with high compression efficiency at present. When implementing Huffman coding, binary tree is used for implementation.
Here is a simple example of Huffman coding. For an article, extract all the words and the number of occurrences. Then how to encod ...
Posted by ununium on Tue, 28 Dec 2021 11:49:57 +0100
Array and memory allocation
1. Array
An array is a container for storing data with a fixed length. The data types for storing multiple data should be consistent.
1.1 array definition format
data type[] Array name
int[] arr;
double[] arr;
char[] arr;
Data type array name[]
int arr[];
double arr[];
char arr[];
1.2 array initialization
Array dynamic initialization
Dy ...
Posted by aswini_1978 on Tue, 28 Dec 2021 10:35:02 +0100
LeetCode - 825 - school-age friends - Java - in the author's opinion, it's fine
subject
Topic analysis
Problem solving thinking 1:
Sorting the array ages (in ascending order) is actually sorting these people according to their age from high to low. At this time, use two "left and right pointers" to lock x's dating range. After confirmation, right - left is the number of people who meet th ...
Posted by niranjnn01 on Tue, 28 Dec 2021 07:25:44 +0100