How to solve BCF (preferably in a proved way)?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
How to solve BCF (preferably in a proved way)?
Название |
---|
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
Yes, it's correct.
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)
We got WA but passed with some additional random strategy. Not sure whether our first solution has some bugs.
abistrigova used backtracking with memoization and restriction on iterations.
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.
If we don't know the two ends?
Bruteforce one of them.
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.
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.
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.
Why 64Mb in F?
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.
What's MITM?
Meet in the middle
How to solve J?
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.
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 -> 0010101011111111111110101
It is not hard to prove that the number of states is now acceptable.
Solution from my team: run random simulation multiple times, print arithmetic mean of number of moves in all simulations.
Don't you need $$$10^{18}$$$ simulations to get the required precision ($$$10^{-9}$$$)?
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.
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.8458781294876384241
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?