### rng_58's blog

By rng_58, history, 3 weeks ago, ,

How to solve BCF (preferably in a proved way)?

• +74

 » 3 weeks ago, # | ← Rev. 2 →   0 D: Is segmented ternary search the correct solution? I am getting WA10,so not sure if it's because my code is wrong or the approach is wrong
•  » » 3 weeks ago, # ^ |   0 Yes, it's correct.
 » 3 weeks ago, # |   0 C: I permuted over the order of kings going to a new column. Other than that, I just made a valid move (either move current king in the order to a new column or just make other valid moves not clicking king)
•  » » 3 weeks ago, # ^ |   +21 We got WA but passed with some additional random strategy. Not sure whether our first solution has some bugs.
•  » » 3 weeks ago, # ^ |   0 abistrigova used backtracking with memoization and restriction on iterations.
 » 3 weeks ago, # | ← Rev. 3 →   +8 In B I bruteforced 3 of the strings which have fewest question marks, then in the last string if we know either first or last symbol, we can find the other one, the same for the second and second to last symbol and so on. It works in $2^{26}n$, but passes in 1 second.
•  » » 3 weeks ago, # ^ |   0 If we don't know the two ends?
•  » » » 3 weeks ago, # ^ |   0 Bruteforce one of them.
•  » » 3 weeks ago, # ^ |   0 Brute force from both borders to middle, with checking s for which all is known works in $O(2^{3n/4})$, because one ? in first two lines can be found because of modulo 4 equation, and one in last two lines can be found. In fact, you don't need to find them, this only proves, that for each s, at least 1/4 of branches will be thrown away imidiatly.
•  » » 3 weeks ago, # ^ |   0 The same proved complexity but probably faster in practice (and works in 5 ms): Do a recursive brute in this order: first and last column first, then going inside, and checking that currently everything is ok.
 » 3 weeks ago, # | ← Rev. 2 →   +8 I have solved F with the following solution:Bruteforce width of the first column(there are only O(1e6) interesting widths). Then, measure the width of the second column with ternary search by the answer.Not sure, if it is correct or not.
 » 3 weeks ago, # |   +42 Why 64Mb in F?
 » 3 weeks ago, # |   0 At first I've tried to solve B with MITM. But ML 64 MB was fighting against me. In the end I've solved it with local optimization.
•  » » 3 weeks ago, # ^ |   +1 What's MITM?
•  » » » 3 weeks ago, # ^ |   0 Meet in the middle
 » 3 weeks ago, # |   0 How to solve J?
•  » » 3 weeks ago, # ^ |   +21 You can find with DP in $O(n \cdot 2^n)$ that the answer is a linear recurrence of order $8$. So you can solve it with Berlekamp-Massey.
•  » » 3 weeks ago, # ^ |   +18 Let $f[S]$ be the possibility that you start from $0$ to state $S$, where $S$ is a $n$-bit integer. The state means you are now at $0$ and a position $k$ is visited if and only if $S_k=1$.For each state $S$, find the first and last $11$, and set all the bits between them to $1$.i.e.0010101011000110000110101 -> 0010101011111111111110101It is not hard to prove that the number of states is now acceptable.
•  » » 3 weeks ago, # ^ |   +16 Solution from my team: run random simulation multiple times, print arithmetic mean of number of moves in all simulations.
•  » » » 3 weeks ago, # ^ | ← Rev. 2 →   +16 Don't you need $10^{18}$ simulations to get the required precision ($10^{-9}$)?
•  » » » » 3 weeks ago, # ^ |   +10 No, only about 10^11 simulations are required. So we had like non-polynomial which passed around 30 tests, and the rest 20 tests we passed with such a precalculation. One test proceeds in about 1 minute on my PC.
•  » » » » » 3 weeks ago, # ^ | ← Rev. 2 →   0 When we repeat simulations $10^{11}$ times and take the average, the standard deviation of the result is multiplied by $1 / sqrt(10^{11})$. So it's very strange that this is accurate enough.My output for $n = 50$ is 3.845878128958. What's yours?
•  » » » » » » 3 weeks ago, # ^ |   0 3.8458781294876384241
 » 3 weeks ago, # | ← Rev. 2 →   +3 I'm doubtful about the validity of test 8 of problem D. I checked if the given polygon was convex, and it failed. Could anybody responsible for the problem take an inspection?