CF 494E Sharti

CF 494E Sharti


Meaning of the questions: a \ (n \ times n \) board, a total of m rectangular grid of white. Two people need game, select each operation does not exceed the length of one side of the square and k flip color, lower right corner of each toggle need white square, turn operation, the operator can not lose.

Solution:
This problem is clearly satisfy Theorem coin flip game, but one-dimensional into a two-dimensional.
\ (sg_ {I, J} = \ min \ {lowbit (I), lowbit (J), maxbit (K) \} \) .
lowbit (x) as x is the least significant bit binary numbers, when maxbit (x) the highest level.
Next to prove this conclusion.

Then give a few lemma.

定义
\(pre_x = \bigoplus_{i=1}^{x} \text{lowbit(i)}\)
\(f(l,r)= \bigoplus_{i=l}^{r} \text{lowbit(i)}\)

Lemma. 1: \ (\ FORALL K \ GEQ. 1 \) , \ (pre_ ^ {2} = 2 ^ {K-K. 1} \)

Proof: Consider everybody's contribution is easy to prove.

Lemma 2: \ (\ FORALL K \ GEQ. 1 \) , so that a set of \ (S_k = \ {pre_x | X \ in [0,2-K ^. 1] \} \) , may prove \ (S_k = [0 , 2 ^ k-1] \ )

Proof: induction, k = 1 is clearly established, when k> 1, \ [S_k = \ {pre_x | X \ in [0,2 ^ {k-1 -1}] \} \ \\ bigcup \ {( 2 ^ {k-1} + 2 ^ {k-2}) pre_x | x \ in [0,2 ^ {k-1} -1] \} \\ = [0,2 ^ {k} -1] \]

Lemma. 3: \ (\ FORALL X \ Y NEQ, pre_x \ NEQ PRE_Y \)
Proof: Lemma 2.

First discuss \ (k = n \) case, i.e. no inversion of the square length limit.

We consider inductive proof.
For the first \ (i \ leq 1 \) or \ (j \ leq 1 \) case, obviously \ (sg_ {I, J} =. 1 \) .
Next, for the \ (i \ leq x, j \ leq y, (i, j) \ neq (a, b) \) conditions are satisfied conclusion, we need to show \ (sg_ {a, b} = \ min \ {lowbit (a), lowbit (
b) \} \) may wish to set \ (lowbit (a) \ Leq lowbit (B) \) , \ (K = lowbit (a) \)
to a number less than 2 ^ k is necessarily have in S, as will be apparent to \ (I <2 ^ K, lowbit (AI) = lowbit (BI) = lowbit (I) \) ,
then for \ (X <2 ^ K, pre_x \ in S \) .
Simply proof \ (2 ^ k \ notin S
\) we are looking for \ (2 ^ K \) , may wish to put a little weak conditions, we just need to find the value \ ([2 ^ k, 2 ^ {k + 1} - 1] \) can be.
Order \ (A-T = 2 ^ K \) , \ (K '= lowbit (T) \)
if\ (a-2 ^ k \ ) or \ (b-2 ^ k \ ) is 0, then it must not be found.
\ (lowbit (a) <lowbit (b) \) when the matrix \ ((a-2 ^ k , b) \) in this position has a \ (2 ^ {K '} \)
\ (lowbit (A ) = lowbit (b) \) when the matrix \ ((a-2 ^ k , b-2 ^ k) \) in this position has a \ (2 ^ {k '}
\) and it is apparent to \ ( 2 ^ k \) is only a side length of a square value of \ (2 ^ {k '}
\) to the position referred to as \ ((a', B ') \) , no matter where we have to put this \ (2 ^ {k '} \) to eliminate
then the new problem is to in (a', b ') of the bottom right, to find a value of \ ([2 ^ {k' }, 2 ^ {k ' +1 -1}] \) square.
(Why is square, because the extra part of the right range or above a certain part of it in \ ([0,2 ^ {k '} - 1] \) ), it will not affect the answer.
Not difficult to find the problem with the original is the same, but after doing a limited number of a, b there must be a will to 0, so the \ (2 ^ k \ notin S \) ,\(\text{mex}\{S\}=2^k\)

We solved this \ (k = n \) problems when (k \ <n \) , the apparent, k will only \ (\ min \ {lowbit ( a), lowbit (b) \}> maxbit (K) \) a \ (sg_ {a, b} \) impact,
provided \ (t = 2 ^ {maxbit
(k)} \) difficult to find, within the side length k, in (a, b) and for the lower-right corner to (2t, 2t) for the lower right corner of the values are the same.
\ (S = \ {f (
x, 2t-1) | x \ in [2t-k + 1,2t] \} \) and \ (2 ^ k> x, lowbit (x) = lowbit (2 ^ kx ) \)
so \ (S = \ {pre_x |
x \ in [0, k-1] \} \) and \ (pre_ {2} ^ {-1}. 1 + K = {K} ^ 2 \) , seen from Lemma. 3 \ (2 ^ K \ notin S \)

Now that you know sg function, we direct scanning line + tree line, as several lowbit very little maintenance to enumerate each lowbit.

Guess you like

Origin www.cnblogs.com/gzy-cjoier/p/11261857.html