
I have an alternative solution for Wildcard Round Medium (Modulo Counters). You can see my code in edit.
The first thing I'll prove is that if you have the real values in the counters instead of the values modulo m then there is a position in the corridor where every fox steped. Assume there is not, then we take out one fox, and for each position he stepped there is at least one fox that didn't step in that position, so we make that fox step in that position. Now we know that if the counters have the real values instead of the values modulo m, the solution (if there is a valid way of stepping that leads to that numbers) is the greatest value of the counters.
Second part of the solution is knowing if there is a solution given the numbers (the original numbers, not the numbers modulo m) of the counters. We know that if there is a solution it is T = greatest value of the counters. So if there are T foxes, the only way of getting that values of the counters is if for every two consecutive positions, every fox steps in at least one of those two positions, then for each i we have to test:
Tcounter[i]+Tcounter[i1] <= T
that is the same as
T <= counter[i]+counter[i1]
Now if for every two consecutive positions all the foxes stepped in at least one of them that is a valid solution. It's easy to prove by induction that you can choose a fox, select the positions where he steps, and take out this fox and the following two equations will stil hold:
max(counter[i]) = T (the new value of T, that will be the original T1) T<= min(counter[i]+counter[i1])
Now another thing we need to prove is that if there area T foxes, and there is a position with its counter equal to R<T then there is a solution with T foxes and with the same value on each counter except for that counter with value R changed for T. It's not hard to prove it as every fox that didn't step on that position can step there.
Now the only thing we need to do is try with the original counter as if it was not modulo m, and then change the minimum value of counter (let's say R) to R+M while the solution is not valid, changing all ocurrences of R to R+M. This need to be done at most 50 times as if all the counters are greater or equal than M but less than 2M then the solution is valid as we can make half of the foxes step on (0,2,4...), half of the foxes step on (1,3,5...) and then make them complete the steps as I proved that we can do.> 