2021.07.16 [NOIP improves Group B] Simulation summary

T1: Play chess

The general idea of ​​the topic: Two players play a game. There are k games running at the same time, and any game can be operated at a time. Each game consists of n*m 01 boards. Each time you can choose (x,y) with a value of 1 and reverse (x',y')(x'<=x,y<=y'), Seeking whether the first mover will win or the second mover will win.
During the exam,
the solution to AC question:
ans^=a[i][1][1];
ans== 1 lyp win
ans== 2 id win
’s method of answering question DL:
Insert image description here
2 and 4 remain unchanged, 1 changes, so change one 1 (except on (1,1)), requires an even number of steps.
So (1,1) means that the first mover will win.

The graduate teacher gave a simpler proof:
(1, 1) will change every time you ask, so... if (1, 1) = 1, I will directly change it to 0 first, and then change it to 0. If it becomes 1, and I change it to 0, I will win.

T2: Library

The main idea of ​​the question: Given a directed acyclic graph, find the minimum variance of the weights from 1 to n.
Simplification of variance:
∑ ( ai − ave ) 2 n \frac{\sum (a_i-ave)^2}{n}n(aiave)2
= ∑ a i 2 + a v e 2 − 2 a i a v e n =\frac{\sum a_i^2+ave^2-2a_iave}{n} =nai2+ave22aiave
= ∑ a i 2 n + ∑ a v e 2 n − 2 a v e ∑ a i n =\frac{\sum a_i^2}{n}+\frac{\sum ave^2}{n}-\frac{2ave\sum a_i}{n} =nai2+nave2n2 a v eai
= ∑ a i 2 n + a v e 2 − 2 a v e ∑ a i n =\frac{\sum a_i^2}{n}+ave^2-\frac{2ave\sum a_i}{n} =nai2+ave2n2 a v eai
= ∑ a i 2 n + a v e 2 − 2 a v e 2 =\frac{\sum a_i^2}{n}+ave^2-2ave^2 =nai2+ave22 a v e2
= ∑ a i 2 n − a v e 2 =\frac{\sum a_i^2}{n}-ave^2 =nai2ave2Then
dp will do (details)

T3: Connect words to form a sentence

The main idea of ​​the question: Given two arrays, there is an operation that can insert b[x] in front of y (x>y), and find the minimum number of operations.
DP (not too greedy to backtrack)

T4: Matrix

The main idea of ​​the question: Given n line segments, find the number of rectangles on the picture.
I came up with a pseudo-correct solution (about n^3)
. Enumerate the two vertical sides, and then enumerate the horizontal lines that intersect at the same time. Record the tot bar, ans+=tot(tot-1)/2; the
maximum number is O(200000000+ )
600+ms$

Guess you like

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