Location>code7788 >text

XYD1006CSPS

Popularity:596 ℃/2024-10-07 19:46:36

T1 key [key findings, simulation, enumeration]

Description

Given two lengths of\(n\) (used form a nominal expression)\(01\) sequences\(a\)\(b\)Each position has a weight.\(c\)
Each operation can move the\(a\) The cost is the sum of the weights of the positions 1 after the operation.
checkmate (in chess)\(a\) change into\(b\) Minimum spend.
\(n\le 5\times 10^3\)

Solution

The following section is organized in a similar\(0/1\) of the form\(a\) because of\(0\)\(b\) because of\(1\)
The hand modeling example plus inference reveals a key property for the\(1/0\) cap (a poem)\(0/1\) In both forms, surely the first thing to put\(1/0\) In descending order, the weights become\(0/0\)Then put the\(0/1\) From childhood to adulthood\(1/1\), which is well understood and simple to prove, will not be repeated here.
But there is a special form\(1/1\), which can be changed in the above operation first to the\(0/1\)And then, finally, it's back.\(1/1\)to minimize the expense, but we don't have a direct way to figure out which ones to change\(1/1\), but what is known is that these few\(1/1\) It must be all\(1/1\) A few of the largest in the
So consider enumerating the first few\(1/1\) need to be in harmony with\(1/0\) The combined ordering becomes\(0/1\) cap (a poem)\(0/1\)And then, with the\(0/1\) The combined ordering becomes\(1/1\), will suffice.
Sorting can be maintained with set or with double pointers, but not sort() every time.

Summary

This question examines observation and reasoning skills, as well as some yardage, and the match requires more hand modeling examples, more thinking, and more reasoning.

T2 Scientific Research Base [Tree Rucksack DP]

Description

Given a weighted tree, find a concatenated block such that no more than one point is not in the concatenated block\(k\) one, and the sum of all edge weights of the connected blocks is minimized by multiplying by two.
\(n\le 10^4\)\(k\le 20\)

Solution

due to\(k\) It's very small, and it's a similar capacity, so let's consider Tree Backpacks.
found\(f(u,i,j)\) denote the number of times a person is considered to be in a position to\(u\) as the root of the subtree, consider the first\(i\) A son with\(j\) The smallest answer for which a point is not selected is transferred as follows, the
\(f(u,i,j)=\max(f(u,i-1,j-t)+f(v,cntson_v,t)+w_{u,v}\times 2)\)
included among these\(i\) This dimension is simply rolled off with a rolling array.

Then counting the total answers only requires enumerating each point of the\(f\) This is why the answer will not be missed, and why there is no need to change the root DP, because the answer must be a connected block, so it must be in a subtree rooted at a certain point, and so this will surely enumerate to the optimal answer.

Summary

Ordinary Tree Backpack question, focusing on a small trick at the end when tallying the answers.