×

# Doubt in Cooking Game

 1 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? Question link: https://www.codechef.com/COOK79/problems/COOKGAME asked 20 Feb '17, 00:55 5★rishi_07 315●1●7 accept rate: 20% 0★admin ♦♦ 19.0k●348●495●531

 1 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$. answered 20 Feb '17, 01:10 6★meooow ♦ 6.5k●6●17 accept rate: 49% unless it's invalid then the answer is 0 (20 Feb '17, 01:12) Yes of course :) (20 Feb '17, 01:15) meooow ♦6★ 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. (20 Feb '17, 02:44) 1 @rishabh.jain9196 don't assume anything that is not mentioned in "constraints" section (20 Feb '17, 02:49)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×61
×24

question asked: 20 Feb '17, 00:55

question was seen: 386 times

last updated: 22 Feb '17, 14:08