I found the scoreboard with solutions to download, so I downloaded blmarket’s solution for B problem (he/she ended 3rd) and found the “problem”.

His/her solution returns for input 11 1 3 value 0.1875, but I think that correct value is 0.166666667 .

Reasoning is simple, based on brute force and one simple observations, that diamonds creates “pyramids” - when N is 1, 6, 15, 28, … no matter how the diamonds slides (right/left), the final shape is perfect pyramid.

For solutions where N = 11, the pyramid contains 6 diamonds (the blue one). When I was drawing that picture I realized, that the numbers for shapes are from Pascal’s triangle and probably this is the problem - for N = 11 the number of ways is not 32, but only 30 shown on the picture.

In the picture there are all possibilities for N from 7 to 11, for easier understanding (N=7 first row on the left, N=8 first row on the right, N=9 2. row, N=10 3. row and finally for N=11).