[jloi2016 / show2016] reconnaissance guard (tree DP)

Considering the tree DP, suppose we have considered the placement of listening points in the current subtree, and the root is u u u. Consider what status we want to record: u u u how fa ...

Posted by Canabalooza on Thu, 06 Jan 2022 04:43:05 +0100

Dynamic programming problem

Fibonacci Title Description: We all know the Fibonacci sequence. Now it is required to input a positive integer n. please output the nth item of the Fibonacci sequence. Problem solving ideas: 1. Recursion 2. Dynamic planning Status: F(n) State recurrence: F(n)=F(n-1)+F(n-2) Initial value: F(1)=F(2)=1 Return result: F(N) Code implem ...

Posted by chieffan on Thu, 06 Jan 2022 00:09:22 +0100

Algorithm -- dynamic programming

dynamic programming definition dynamic programming (DP): finding the optimal solution under multiple branches working principle To solve a complex problem, first solve its sub problems (first solve the sub problems, and then gradually solve the big problems) This is a typical recursive idea, eg: fiborache sequence Application scenario T ...

Posted by jbruns on Wed, 05 Jan 2022 01:45:34 +0100

LeetCode-416. Split equal sum subset

Topic source 416. Segmentation and subsets Title details Give you a non empty array containing only positive integers, {nums. Please judge whether this array can be divided into two subsets so that the sum of the elements in the two subsets is equal. Example 1: Input: num = [1,5,11,5] Output: true Explanation: an array can be divided into [1, 5 ...

Posted by mattcass on Tue, 04 Jan 2022 08:12:18 +0100

[training question 47: probability dp | dynamic programming | optimization] Increasing Subsequence | 2021 Niuke summer multi school training camp 1 question I

meaning of the title Increasing subsequence 2021 Niuke summer multi school training camp 1 Count Reg n n Array of n, No i i i number is ...

Posted by Rowno on Tue, 04 Jan 2022 03:00:12 +0100

[data structure and algorithm] in-depth analysis of the solution idea and algorithm example of "stone game V"

1, Title Description Several stones are arranged in a row. Each stone has an associated value. The associated value is an integer, which is given by the array stoneValue.Each round of the game: Alice will divide the line of stones into two non empty lines (i.e. the left line and the right line); Bob is responsible for calculating the value of ...

Posted by Hobgoblin11 on Mon, 03 Jan 2022 09:08:51 +0100

❤️ "Disgusting work" a blog takes you to master the "five core algorithms" ❤️

catalogue 1, Divide and conquer Ideological principle Specific steps Example 1 Algorithm conclusion 2, Dynamic programming algorithm Ideological principle Specific steps Algorithm implementation Algorithm conclusion 3, Backtracking algorithm         Algorithmic thought         Basic steps         Example 2         Algorithm imp ...

Posted by miraclewhipkey on Mon, 03 Jan 2022 07:23:48 +0100

Minimum path covering and minimum chain covering Dilworth theorem: minimum chain covering is equal to the longest inverse chain (detailed proof and classical examples)

1, Minimum path coverage definition Minimum path covering means that in a directed acyclic graph, all points in the graph are covered with the least and disjoint simple paths. solution ① Disassemble each point in the original drawing (disassemble point u into U and u+n); ② Set each edge < u, V > in the original graph to the correspond ...

Posted by hotcigar on Mon, 03 Jan 2022 00:57:13 +0100

Linear DP solves the respective selection problem (grid access, ZG and GG paper transfer, paper transfer)

Original title link: Grid access Grid access Classification: two dimensional can enter a point repeatedly without repeated calculation Set n × In the square graph of N, we fill some squares with positive integers, while others with the number 0. As shown in the figure below: Starting from the upper left corner A in the figure, someone ca ...

Posted by paruby on Sun, 02 Jan 2022 19:22:03 +0100

01 knapsack problem (explanation of state transition equation)

1. Topic introduction: There are N # items and a backpack with a capacity of V. each item has its own value and can only be selected once. Under the limited backpack capacity, the total value of the loaded items is the largest. "0-1 knapsack" is a relatively simple dynamic programming problem and the basis of other knapsack problems ...

Posted by DigitHeads on Sat, 01 Jan 2022 19:38:20 +0100