2021.07.10 [NOIP improves Group B] Simulation summary

TheSwaps

Did you think about the probability for a long time during the exam? ? ? expect? ? ? random? ? ? Two hours of coolness...
? ? ? Rule question? ? ? I don’t want to say anything, I won’t push, I will use violence.

Mixing Chemicals

The original question is old and I don’t have time to type it...
My method is different from the solution.

The main idea of ​​the title:

There is a base ring tree forest. Two connected points cannot choose the same number (1~k) at the same time. Ask about the number of options.

Method 1

My method.
If it is an ordinary forest, it will be a simple tree DP.
f [ i ] [ j ] = ∑ sum [ son [ i ] ] − f [ son [ i ] ] [ j ] f[i][j]= \sum sum[son[i]]-f[son[i ]][j]f[i][j]=sum[son[i]]f [ so n [ i ] ] [ j ]
Therefore, one edge on the ring of the base ring tree can be temporarily deleted, and it becomes the tree D above .
Then notice that the two points on this edge cannot have the same number,
so... let one of them be numbered 1 (which means onlyf [ u ] [ 1 ] f[u][1]f [ u ] [ 1 ] has value), then put anotherf[u][1]f[u][1]f [ u ] [ 1 ] is constant 0, and the result *k is the answer (the reason isuuu can choose 1~k)

Method 2

Use color polynomial formula to find quickly.

Confession

An almost naked 01 fractional programming, nested with dynamic programming, no need to explain much.

Game show

Process in two steps:
Step 1: Simplify the problem, assuming there is no limit to k, and assume that the total number of solutions is x.
Step 2: Consider the limitation of k. Since k<7, you can exhaustively select 0 for n programs, 1 for n programs, 2 for n programs, 3 for n programs, and 3 for n programs. , take 4 for n programs, 5 for n programs, and 6 for n programs. After exhausting these situations, you can know which solutions are legal. And Combinations(34,0) + Combinations(34,1) + Combinations(34,2) + Combinations(34,3) + Combinations(34,4) + Combinations(34,5) + Combinations(34,6) = 1676116.
That is to say, this exhaustive list does not exceed 1676116 times. Let the total number of options in the second step be y.

Then, the final answer that should be output is x - y.

The calculation results can be searched for the plan number y in the second step. The following focuses on how to find the plan number x in the first step.
Since the maximum n is 34, direct search will time out. The n programs can be evenly divided into two parts, that is, the 1st to n/2th programs are classified as part 1, and the n/2+1 to nth programs are classified as part 2.

Part 1: Obviously there are only 17 programs at most. Each program can be taken or not. To exhaust all situations of these 17 programs, there are obviously 2^17 ways to take them. For each method, team A has a score. , set as scoreA, team B also has a score scoreB, and team C also has a score scoreC. Let's assume difAB1 = scoreA - scoreB, difAC1 = scoreA - scoreC, that is, each method can calculate a pair of values ​​(difAB1, difAC1),

Part 2: Apparently there are only 17 shows at most. Each program can be taken or not. If we list all the situations of these 17 programs, there are obviously 2^17 ways to take them. In the same way, for each method, let difAB1 = scoreA - scoreB, difAC1 = scoreA - scoreC, that is, each method can calculate a pair of values ​​(difAB2, difAC2),

Obviously, if a plan is to be established, it must simultaneously satisfy:
difAB1 + difAB2 > 0 (that is, the total score of team A is higher than the total score of team B)
difAC1 + difAC2 > 0 (that is, the total score of team A is higher than the total score of team C) high score)

Therefore, the problem is transformed into, enumerate a pair of values ​​(difAB1, difAC1), and query how many pairs (difAB2, difAC2) there are in part 2, so that difAB1 + difAB2 > 0 difAC1
+
difAC2 > 0 is satisfied at the same time.

Obviously, for part 2, you can use a data structure such as a tree array or a line segment tree to save it for the query in part 1.

Since the answer is found in two steps, the time complexity = x + y = 2^17 * Log(2^17) + 1676116

Guess you like

Origin blog.csdn.net/zhy_Learn/article/details/118684098