The question quotes:
“Now Chef is asking you to count the number of ways to fill the missing numbers (ie. the -1s) of the array with level numbers, so that it corresponds to a valid game. Since the answer can be large, output it modulo 109+7.”
So, if there is no missing number the count is zero.
But the solutions getting accepted outputs answer 1.
Why?
Actually the count is 1, because not substituting any -1 anywhere where there are no -1s to substitute is a valid way and the only one. This is similar to the fact that the number of ways of ordering 0 objects is 1, in other words 0!=1. Or that the number of ways to choose 0 objects from a collection of n is 1, which means {n \choose 0} = 1.
@kingofnumbers@meooow : The problem statement stated the rules for playing the game as “Chef will start in level 1 and whenever Chef passes a level in this game he will advance to the next level, but if Chef fails, he will return to level 1.” How come then, the answer is 0 for any test case. I understand that if the sequence is invalid the solution would be 0, but as the statement clearly states the rules, and it is not mentioned anywhere that chef’s memory can be wrong or he can play an invalid game, is the assumption of a valid game wrong? Please correct me if I am wrong.