Cf580D. Kefa and Dishes (shape pressure dp)

meaning of the title $n $food, each food has a satisfaction, from which choose $m $to make the satisfaction maximum. There is also a $k $relationship: if $x_i $is eaten before $y_i $it will cost $C_i $ Sol The official question was $O (2 ^ n ^ 2)$, but I didn't find any connection between states, so I wrote a $O (2 ^ n ^ 3)$one, but the wat ...

Posted by sdizier on Sun, 03 Feb 2019 16:00:16 -0800

C++ Grammar Tips

Preface Written in disorder, all kinds of content. Just to record it. And the content is extremely imprecise (yes, only practice, no theory)! Please drive carefully! Compulsory inline #define Inline __inline__ __attribute__((always_inline)) Local test results: It's no use adding or not adding inline and inline after O 2 is turned on. Inline ma ...

Posted by Moocat on Sun, 03 Feb 2019 01:03:15 -0800

Cf250D. The Child and Sequence

meaning of the title Title Link Single point modification, interval mod, interval sum Sol If x > mod, then x% mod < x / 2 Prove: Ordinary is easy to see. Following the example above, it is obvious that: The answers to the exercises are brief. It is not difficult for readers to prove themselves. And vice versa. The deduction is natural. T ...

Posted by shaitand on Fri, 01 Feb 2019 22:24:15 -0800

Cf375D. Tree and Queries

meaning of the title Title Link Given a tree with n nodes, each node has a color c i. Question q times, and ask how many colors (> k) appear in the subtree rooted by v node each time. The root node of the tree is 1. Sol Think of the chairman tree and heuristic merger. Obviously they can't. Calculated as dfs in the order of violence. Bow to ...

Posted by whitepony6767 on Fri, 01 Feb 2019 02:09:15 -0800

Disabled Word Detection

utf8 encoded data can be directly used by the following code The most critical step is to split the string into a single word, UTF-8 coded word, if there is only one byte, its maximum binary bit is 0; if it is multi-byte, its first byte starts from the highest bit, the number of consecutive binary bit values of 1 determines the number of bits ...

Posted by Dale on Thu, 31 Jan 2019 03:18:16 -0800

LeetCode 215 -- the K-th largest element in an array

1. topic Find the kth largest element in an unordered array. Note that what you need to look for is the kth largest element after the array is sorted, not the kth different element.Example 1:Input: [3, 2, 1, 5, 6, 4] and k = 2Output: 5Example 2: Input: [3, 2, 3, 1, 2, 4, 5, 5, 6] and k = 4Output: 4 Explain:You can assume that k is always valid ...

Posted by thumrith on Wed, 30 Jan 2019 18:12:15 -0800

Several Key Functions of set Container

set is very useful in OI. Several common functions qwq are summarized. #include<iostream> #include<cstdio> #include<set> //set Common usage of containers using namespace std; //Customized sorting rules can be achieved by using parody functions class R { publi ...

Posted by gilmourt on Wed, 30 Jan 2019 13:24:14 -0800

c/c++ linux Interprocess Communication Series 3, using socketpair, pipe

linux Interprocess Communication Series 3, using socketpair, pipe 1. Using socketpair to realize interprocess communication is bidirectional. 2. Using pipe to realize interprocess communication The key point of using pipe: fd[0] can only be used for receiving, fd[1] can only be used for sending, it is one-way. 3. Use pipe and write in with ...

Posted by e11even on Tue, 29 Jan 2019 08:27:16 -0800

BZOJ2438: [Zhongshan Selected 2011] Homicide Game (tarjan)

meaning of the title Title Link Sol This question is a test of reading comprehension. If you can read it, it's not difficult to find out that this is how many points with a degree of (0\) are counted. Judge after the shrinkage point Of course, there is an exception \(1-> 3, 2-> 3), that is, there is an isolated point, can be judged. When ...

Posted by eddie21leeds on Mon, 28 Jan 2019 00:00:15 -0800

LeetCode 25-K Flip Lists

1. topic 2. answers Firstly, the summary points of the linked list are determined by the fast and slow pointers. When there are even nodes, the number of nodes is equal to i* 2. When there are odd nodes, the number of nodes is equal to i* 2 + 1. Then each K nodes of the linked list are divided into a group. Loop to sublist for each group Fl ...

Posted by tave on Sat, 26 Jan 2019 12:42:14 -0800