Some questions of CF

Manthan, Codefest 19

A. XORinacci

Description

Define a function \ (F (n-) \)
\ [F (n-) = \ the begin {A} & Cases (n-= 0) \\ & B (n-=. 1) \\ F (n--. 1) \ F Oplus (n - 2) & (n
> 1) \ end {cases} \] now given \ (a, B, n-\) , you need to find \ (f (n) \) values

\(a, b, n \leq 10^9\)

Solution

We found that the minimum cycle section of this function is \ (3 \) , so we direct to \ (n \ bmod 3 \) classification talk about it

B. Uniqueness

Description

Given a length \ (n-\) sequence, you can select the number of a delete section, such that the remaining number you pairwise disjoint. Q. requires a minimum number of digits deleted

\ (N \ leq 2000 \)

Solution

We found that after the deletion occurs once every digital need to ensure that most, so when the right move to delete range, certainly not the left point moves to the left. So the left point on the right end point monotonous, so we \ (two ~ point \) just fine, and we need to open a barrel to maintain the rest of the digital number

C. Magic Grid

Description

A (n * n \) \ matrix, you need to digital \ (0 \) to the \ (n ^ 2 - 1 \ ) This \ (n ^ 2 \) numbers do not leak to fill wherein you need to ensure that the same exclusive-oR of each row of each column, a legitimate request for an arbitrary scheme

\ (n-\ Leq 1000 \) , and \ (n-\) is \ (4 \) multiple

Solution

There are two properties on XOR

  1. For an arbitrary natural number \ (K \) , satisfy the \ (4k \ oplus 4k + 1 \ oplus 4k + 2 \ oplus 4k + 3 = 0 \)

  2. For an arbitrary natural number \ (K \) , satisfy the \ (k \ oplus k + 4 \ oplus k + 8 \ oplus k + 12 = 0 \)

所以,我们就可以直接构造了,大概就像下面这个样子
\[ \begin{matrix} 0&1&2&3&32&33&34&35 \\ 4&5&6&7&36&37&38&39 \\ 8&9&10&11&40&41&42&43 \\ 12&13&14&15&44&45&46&47 \\ 16&17&18&19&48&49&50&51 \\ 20&21&22&23&52&53&54&55 \\ 24&25&26&27&56&57&58&59 \\ 28&29&30&31&60&61&62&63 \end{matrix} \]

D. Restore Permutation

Description

Has a length \ (n-\) a \ (1 \) to the \ (n-\) arranged \ (P_i \) , we define \ (s_i = \ sum \ limits_ {j = 1} ^ {i - 1} [p_j <p_i] \ cdot p_j \)

Now tell you \ (s_i \) sequence, you need to pour launched \ (p_i \) sequence

\ (N \ leq 2 \ times 10 ^ 5 \)

Solution

We can consider press \ (p_i \) from small to large order to restore each number. First we look at the current \ (s_i \) What position \ (0 \) , then the last \ (s_i \) to \ (0 \) location \ (pos \) it must be necessary to restore the current number. This position is then thrown away, and then the interval \ ([pos + 1, n ] \) each in the \ (S_I \) are reduced by subtracting the number currently

Why do we consider this way is right, if we find a number smaller than all numbers have been deleted, then the current figure is obviously necessary to restore the figures. When there are multiple locations \ (s_i \) to \ (0 \) , we want to give priority to a position behind. Because the next step is to fill in a few numbers are not the same, we did not let them influence each other, it can only reverse fill every position

E. Let Them Slide

Description

A \ (n-\) OK \ (W \) column board, each line having a length \ (L_i \) slider, a position of each slider has a weight \ (a_ {i , j} \)

Now you are free to translate all sliders (can not be moved to another line, we can not go beyond the boundaries of the board), ask you for the first \ (\ forall j \ in [ 1, w] \) columns may appear and maximum weights how much, between independent inquiry

\ (1 \ leq n, w, \ sum l_i \ leq 10 ^ 6, l_i \ leq w, | a_ {i, j} | \ leq 10 ^ 9 \)

Solution

We can consider the contribution of each row of sliders for each column, we find that for any one number can affect are some interval, if a position is more interval contains, we have the right to take the maximum value. In this way the current slide contribution different intervals for all columns only \ (\ mathcal {O} ( l_i) \) months, we added these contributions directly to the answers inside it

I started also a SoftBrands, with a tree-like array to maintain the contribution, and later found that the direct difference on it, because it just finally find the answer again

When seeking influence each slider for each interval, I was directly \ (set \) do, in fact, can directly engage with a double-ended queue. Because the length of each interval Effects are the same numbers

Educational Codeforces Round 71

E. XOR Guessing

Description

This is an interactive title

There is a hidden numbers \ (x \) , you have to launch by no more than twice asking \ (x \) values. You can ask each given a length exactly \ (100 \) sequence, and the interaction library returns a value of a random sequence of different positions or \ (X \) is the result, in any of a number of all query only appears once

Title involved ownership values are \ (\ in [0, 2 ^ {14}) \)

Solution

This is a drop of wisdom topic

This question is directly asked to come up with a \ (x \) before \ (7 \) value of the bit, then after a come up \ (7 \) value is gone bit, is to let the inquiry that \ ( 100 \) number in a (7 \) \ the bits are \ (0 \)

F. Remainder Problem

Description

Give you a number of columns, the need to support \ (q \) times the following two operations

  1. To position \ (X \) numbers on the increase \ (Y \)
  2. All query mode (x \) \ meaning as under \ (y \) value and the location

\ (Q \ leq 5 \ times 10 ^ 5, TL = 4s \)

Solution

Let us not be intimidated by this question of the range of data, in fact, this question directly block on it

We consider for \ (\ leq \ sqrt n \ ) modulo a pre-processing the answer remainder of each, when violence in the modified update click on it

For \ (> \ sqrt n \) modulus of direct violence to traverse the query again

Guess you like

Origin www.cnblogs.com/xunzhen/p/11431684.html