108 simulation solution to a problem

A. play table

The correct meaning of the questions is: find the absolute value of the difference between the expected value and the answers achieved under optimal decision.

Taking into account the probability of this question in two selected each half.

Both choose their optimal strategy, as the case may be divided in a bit,

Only $ 0 $, $ 1 $ two values, choose $ 0 $ if the former, then the latter can choose $ 1 $

The final each index will be equal probability of selection, the final answer is sums in addition to the absolute value of $ 2 ^ k $.

 

 

 

B. snake

Consider all options must be expressed as

1. From the starting point, take the $ a $ step backward, then forward away $ a $ step back.

2. forward to go up and down wildly.

3. End the bounce, take $ b $ step forward, then reverse take $ b $ step back.

($ A $, $ b $ both be 0)

Hash string matching determination, a pretreatment step $ $ 1, $ 3 $, $ 2 $ Step $ DP $ directly on it.

Provided $ dp_ {i, j, k, 0/1} $ j represent row i column to the k th matched, the state from a / transferred from this column.

It can be a simple transfer.

In order statistics do not leak, there are a lot of details.

May wish to step $ 1 $, $ 3 $ are treated as left and right parentheses.

Take only $ 1 $ step left and right parentheses are not necessary to answer the statistics, because statistics have been in the $ dp $.

Some $ dp $ can not handle the situation around the brackets directly matched, so it should be special statistics.

In the case of direct matching of individual brackets, only statistics once.

Guess you like

Origin www.cnblogs.com/skyh/p/11831000.html
Recommended