Detailed explanation of C + + class template: concept and basic usage

Similar to function templates( Detailed explanation of C + + function template (1): concept and characteristics ), classes can also be parameterized by one or more types. For example, a container class is a typical example of this feature, which is often used to manage certain types of elements. As long as we use class templates, we can impleme ...

Posted on Mon, 10 Feb 2020 21:50:39 -0800 by crash58

Numbers that appear more than half the time in the array (C++ Swordfinger Offer details)

The first time I saw this question, it was so simple as to burst. Or sort function sorting, median, traversing the number of times is OK?But during an interview, sort may let you do it yourself, or the title requires: Can't you modify the input array???The first method (based on the Partition function)Note: This method modifies the input array ...

Posted on Fri, 07 Feb 2020 22:11:55 -0800 by bluntster

C + + understand the realization principle of polymorphism

Virtual function and polymorphism 01 virtual function In the definition of a class, a member function with a virtual keyword in front of it is called a virtual function; The virtual keyword is only used in the function declaration in the class definition, not when writing the function body. class Base { virtual int Fun() ; // virtual fu ...

Posted on Sat, 01 Feb 2020 01:58:04 -0800 by haaglin

Luogu P2742 [template] two dimensional convex hull

meaning of the title Convex hull Sol Andrew algorithm: First, rank $x $as the first key and $y $as the second key from small to large, and delete duplicate points Using stack to maintain points in convex hull 1. Put $p UU 1, P UU 2 $in the stack 2. If $p {I {(I > 3)} $is to the right of the line $p {I - 1}, P {I - 2} $, the top of the ...

Posted on Fri, 31 Jan 2020 05:42:45 -0800 by ONiX

P1251 napkin planning problem in Luogu (minimum cost and maximum flow)

meaning of the title A restaurant needs $r_i $napkins on the $I $day. There are three ways to get napkins every day 1. Buy for $p $ 2. Send it to the express department for $f $and take it out in $m $days 3. Send it to the slow cleaning department for $s $, and take it out after $n $ Ask the minimum cost when meeting the requirements Sol ...

Posted on Fri, 31 Jan 2020 03:09:44 -0800 by synapp2

BZOJ2938: [Poi2000] Virus (AC Auto)

Orz wlp 5min finished with suffix array meaning of the title Give $n$0, 1 string Ask if you can construct an infinite string so that it does not contain any strings Sol At first I tried to pretend I didn't know it was an AC automaton and do it.qwq was found to be impossible at all. If you know this can be done with AC automata, you can do ...

Posted on Tue, 21 Jan 2020 10:28:40 -0800 by Duswa

Luogu P2024 [NOI2001] food chain

Title Link Click here ww   Title Description In the animal kingdom, there are three kinds of animals a, B and C. The food chain of these three kinds of animals forms an interesting ring. A eat B, B eat C, C eat a. There are N animals, numbered 1-N. Every animal is one of a, B and C, but we don't know which one it is. There are two ways to descr ...

Posted on Mon, 06 Jan 2020 23:46:28 -0800 by sumfight

BZOJ4241: Historical Research (rolling back team Mo)

meaning of the title Give the number of $n $, the maximum value of each number * occurrence times within $[L, R] $of each query interval Sol Roll back team Mo, whose name is Zhenmeng qwq Consider that if we use normal Mo team, we can't delete it, because once we delete the largest element, we can't find the next largest element At this tim ...

Posted on Mon, 06 Jan 2020 01:20:25 -0800 by bloodgoat

CPP design mode learning

Source address: https://www.ev0l.art/index.php/archives/20/ Memo mode A pattern that records the snapshot state of another class within one class. It can be used to jump back at the right time There are three steps in the design memo: Node of design record, storage record2. Storage of design records: vector list map set can make the list ...

Posted on Sun, 05 Jan 2020 14:53:04 -0800 by southofsomewhere

Bzoj4299: codechef frbsum (Chairman tree)

meaning of the title Title Link The forbbiddensum of the data set s is defined as the smallest non negative integer that cannot be represented by the sum of a subset of S (which can be empty). For example, if S={1,1,3,7}, then its subset and contains 0(S' = ∅), 1(S' = {1}), 2(S' = {1,1}), 3(S' = {3}), 4(S' = {1,3}), 5(S' = {1, 1, 3}) ...

Posted on Sat, 04 Jan 2020 23:59:12 -0800 by JonathanV