# Uoj Goodbye dingyou Round

Source: Internet
Author: User

2.14 Night of the game, now changed the four questions, but also the answer. Here's a puzzle.

New Year's Xordescription

give you \ (n\) , and then you construct \ ([L, R], l<r\) make interval xor ( n\)

Solution

Many of the practices are

My method is special ( n\le 4\) , and then for odd use \ ([n-3,n-1]\) , even with \ ([N-4, n]\)

New Year's Leaves description

A tree \ (n\le 5e5\) , each time the leaves of a primitive tree will be randomly dyed black, ask the white point the furthest distance from when to become small

Solution

The nature of the diameter: the distance from the midpoint of all diameters \ (\le 1\) (Proof of evidence)

We randomly find a diameter of the end of the root of the achievement.

When the diameter length \ (d\) is even:

? There are several key subtrees (that is, subtree with key leaves)

? Here the key leaves are defined as \ (Dep=\frac d 2\) leaves

? The longest chain becomes smaller when the key leaves are not all black in one key subtree.

When the diameter length \ (d\) is odd:

? All leaves with a length of \ (dep = \lceil\frac d 2\rceil\) must be in the same subtrees tree, and these leaves are called the key leaves of that subtree.

? The key leaves in the other subtrees are \ (dep = \lfloor\frac d 2\rfloor\) .

? The longest chain becomes smaller when the key leaves are all black or the bottom is full black.

? If the depth is not the largest of the sub-tree merging, you can use the straight length of an even number of methods to deal with

Procedure 1:

Enumerate which key subtree is finally left, set that tree to have \ (s\) a key leaf, the remaining \ (i\) key leaves at the end of dyeing

Set the total number of key leaves to \ (n\), the total number of leaves is \ (tot\)

When the remaining \ (k\) key leaves are not black, it is necessary to expect \ (\frac {tot} k\) steps to dye one more key node.

$\sum_{i=1}^s \frac{\binom s I \binom{n-s}{1} (n-i-1)!} {n^{\underline{n-i}}} \sum_{j=n-i}^n \frac{tot}{j}$

Procedure 2:

Enumerate which key subtree is left, and then regardless of the subtree, the desired time to dye the remaining subtree black

It's obviously going to be a lot.

Notice that for a lot of parts, all the key leaves must be dyed black, but the final black is not in the current subtree.

Order \ (E (x) \) the expected time of the x\ subtree to black all the key leaves and finally the black color

The total number of parts is: (with \ (l\) a key subtree)

$\sum_{x=1}^l\sum_{y\neq x} e (y) = \sum_{y=1}^l e (y) (L-1)$

New Year's five dimensional geometry description

\ (n=5\) a real variable, the value range of \ ( i\) variable is \ ([L_i, r_i]\)

The given matrix \ (a\).

Ask each variable in the range of values at random, how much probability makes \ (X_i-x_j\ge a_{i, j}\) all set up

\ ( -10\le l_i, R_i, A_{i, J} \le 10\), and all integers

Partial Score

Tell a more meaningful part of the section: \ (if J\neq i+1, a_{i,j}=-10\)

Because \ (x_i-x_j\) must \ (\ge-10\), so this part is equivalent to we only need to consider the limitations of neighboring variables

Set \ (f_i (x) \) is \ (x_i \le x\)and \ (x_i,\cdots,x_n\) the probability of satisfying the limit (\ (f_{n+1} (x) = 1\))

We have
f_i (x) = \left\{\begin{aligned}&0&&x\lt l_i\\&\frac{1}{r_i-l_i}\int_{l_i}^x f_{i+1} (y-a_{i,j}) dy && l_i\le x\le r_i\&f_i (r_i) && x\gt r_i\\end{aligned}\right.
Notice that \ (f_i (x) \) is the polynomial of the \ (O (n) \) segment, we can make each integral and then pan

For the fixed integral processing method: Because \ (l_i\) is a constant, we calculate the indefinite integral, then the whole minus a constant can

Finally cut out \ ([L, r]\), fill the next two paragraph can be

(No implementation, wrong point)

Solution

Note The special properties: the range of values, the limit is an integer.

\ (l_i=r_i\) variables are not discussed (a few things will be better)

Consider variables for \ (l_i\lt r_i\) , we set \ (x_i = p_i+q_i\), \ (p_i\in[l_i, R_i) \in Z, q_i\in[0, 1) \in r\)

Then we \ (O (10^n) \) enumeration \ (p\), calculate the corresponding probability, averaging is the answer to the request

Consider restrictions \ (P_i+q_i-p_j-q_j\ge a_{i,j}\)

There is \ (Q_i-q_j\ge p_j-p_i+a_{i,j}\) , the right \ (\ge 1\) no solution, \ (\le-1\) when the limit is invalid

The right side is \ (0\) when the variable is equivalent to \ (Q_j\le q_i\) . In the case of random scatter, it can be regarded as \ (q_j\lt q_i\) .

Since the probability of the relative size order of the random scatter (n!\) is the same, we can turn to count the number of relative size order to satisfy the condition. Pressure or sudden-search

Total complexity \ (O (10^N2^NN) \)

New Year's Code description

give you length \ (5e5\) \ (rgb\) string \ (S, t\), ask from \ (s\) at least how many times to go to \ (t\)

Action (1): Select two neighboring bits of different colors to turn them into a third color except for them (RG-BB)

Action (2): Select two adjacent bits of the same color to turn them into different new colors (BB---RG/GR)

Solution

Give \ (R, G, b\) a random ( 012\) designator (post-label \ (S\to A, t\to b\))

Then discover that each operation is equivalent to a +1 in the meaning of \ (\bmod 3\) , another 1

Conversely, the +-1 of adjacent bits is not necessarily an operation

Consider a prefix and \ (SA, sb\) in the sense of \ (\mod 3\)

The original operation is equivalent to the single point \ (\pm 1\)of the prefix and sequence, and the original target is equivalent to having two prefixes and sequences equal after a wave operation

Consider segmenting by the location of \ (sa\equiv sb\pmod 3\) . (each segment contains the rightmost \ (sa=sb\) location)

So obviously for a length \ (n\) segment, at least operate \ (n-1\) times.

It then operates at most \ (n\) times according to the subsequent construction, so each segment needs to be manipulated \ ([N-1, n]\) times

So far, only paragraphs and paragraphs have been considered independent. Consider induction:

Inductive basis: If a section at the junction of the operation to make two paragraphs merge, and then no longer merge segments, then set the length of \ (A, b\) of the segment, the original to \ ([A+b-2, a+b]\) times, merging words to \ (1 + [a+b -1, a+b]\) times. Not excellent

Induction: After each merge segment into the induction sub-state, not excellent.

Then we follow the operation method used in the following structure, doing \ (dp\)

\ (dp[i][u][v]\) indicates that the position of section \ (i+1\) is to be changed from \ (u\ ) to (v\) , what is the cost of the former \ (i\) position

Then there are two possible actions: (The operation is executed from top to bottom, each action turns the previous line into the next)

case 1:      a[i+1]    u   w    v b[i+1]case 2:    u a[i+1]    v   w      
Structure

If \ (a\) Middle Head is the same color, it may be set to \ (00\)

Then if \ (b\) in the middle of the head is \ (1/2\), one-step operation to change the paragraph head, recursive. Otherwise, do not change the paragraph head, directly into the recursive

If \ (a\) Middle Head for different colors, it may be set to \ (01\)

If \ (b\) in the middle of the head is \ (2\) , one-step operation recursion. If \ (0\), direct recursion

If \ (10\) , then \ (01\to 22\to 10\) Two steps to complete the two positions, recursion two levels

If it is \ (11\) , the second position in \ ( a\) becomes \ (2\), then \ (02\to 11\) , after the first recursive operation.

If \ (12\) , the same first operation, the second position in \ (a\) into \ (0\), and then \ (00\to 12\)

Construction is complete.

The question comes: will you always borrow to the Duan and borrow it back?

From the angle of the prefix and the borrow equivalent to fix the first, then fix yourself. Then the end of the paragraph does not need fix yourself.

(I remember I didn't do that before.) I don't know what I was doing when I wrote the puzzle. I do not know if this understanding is wrong, please point out the wrong.

New Year's vote

No, not yet. Dig a hole.

Uoj Goodbye dingyou Round

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.