{"trustable":true,"prependHtml":"\u003cstyle\u003e.statText pre { font-size: 12px; }\ntable {display:block !important; width:100%; }\ntable tbody {display:block !important; width:100%; }\ntable tbody tr { width:100% !important;display: block;}\ntable tbody tr td.statText { margin-left: 5px; display: inline-block; width: fit-content; }\ntable tbody tr td.statText br { display: block; content: \" \";line-height: 12px;margin: 12px 0;}\ntable tbody tr td.statText table table pre {\n white-space: pre-wrap;\n text-overflow: ellipsis;\n word-break: break-all;\n}\ntd { padding: 0 !important; border: none !important; }\npre { line-height: normal; margin: 0; }\n\u003c/style\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\n \n \t\t\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003ch3\u003eProblem Statement\u003c/h3\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eWe are playing a game with some of coins on a rectangular board.\nThe board is divided into unit square cells.\nEach cell is either empty, or it contains an obstacle.\nThe board is given to you as a String[] \u003cb\u003eboard\u003c/b\u003e.\nThe character \u0027#\u0027 represents an obstacle and \u0027.\u0027 is an empty cell.\n\u003cbr\u003eWhen starting the game, the player places coins into some of the empty cells.\nThe number of coins and their positions are chosen by the player.\nThe only restriction is that the player may not place two coins into the same cell.\n\u003cbr\u003eNext to the board, there are 4 buttons labeled \"Left\", \"Right\", \"Up\", and \"Down\".\nThe game is played by pushing these buttons.\nWhen the player pushes a button, all coins will try to move one cell in the corresponding direction.\nFor each coin, there can be three different outcomes:\n\u003cul\u003e\n\u003cli\u003eIf the next cell in the chosen direction contains an obstacle, the coin remains in its current cell.\u003c/li\u003e\n\u003cli\u003eIf there is no next cell in the chosen direction (i.e., if the coin is already on the corresponding edge of the board), the coin falls off the board.\u003c/li\u003e\n\u003cli\u003eIn all other cases, the coin moves one cell in the chosen direction. (Note that this includes the case when the destination cell currently contains another coin. In this way it may happen that there will be multiple coins in the same cell.)\u003c/li\u003e\n\u003c/ul\u003e\n\u003cbr\u003eThe goal of the game is to make some coins (at least one) fall off the board, while some others (at least one) still remain on the board.\nThe initial configuration of coins is called \u003ci\u003egood\u003c/i\u003e if there is a sequence of buttons that can be pushed to win the game from that configuration.\nReturn the number of good initial configurations, modulo 1,000,000,009.\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u0026nbsp;\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003ch3\u003eDefinition\u003c/h3\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003eClass:\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eCoinsGame\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003eMethod:\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eways\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003eParameters:\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eString[]\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003eReturns:\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eint\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003eMethod signature:\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eint ways(String[] board)\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e(be sure your method is public)\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u0026nbsp;\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003ch3\u003eConstraints\u003c/h3\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" valign\u003d\"top\" class\u003d\"statText\"\u003e-\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003cb\u003eboard\u003c/b\u003e will contain between 1 and 40 elements, inclusive.\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" valign\u003d\"top\" class\u003d\"statText\"\u003e-\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eEvery element of \u003cb\u003eboard\u003c/b\u003e will have the same length, and this length will be between 1 and 40, inclusive.\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" valign\u003d\"top\" class\u003d\"statText\"\u003e-\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eEach character in each element of \u003cb\u003eboard\u003c/b\u003e will be one of \u0027#\u0027 and \u0027.\u0027.\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u0026nbsp;\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003ch3\u003eExamples\u003c/h3\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" nowrap\u003d\"true\" class\u003d\"statText\"\u003e0)\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e{\"..\"}\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003eReturns: 1\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003eThe only way to win the game on this board is to start by placing a coin on each cell.\nYou can then push either of the buttons Left and Right to make one coin fall off.\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" nowrap\u003d\"true\" class\u003d\"statText\"\u003e1)\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e{\"##.#\",\n \".###\",\n \"###.\",\n \"#.##\"}\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003eReturns: 11\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003eYou cannot win the game if you use less than two coins.\nOn this board, any configuration with at least two coins can be won (by a single push of some button).\nHence, the answer is C(4,2) + C(4,3) + C(4,4) \u003d 6 + 4 + 1 \u003d 11.\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" nowrap\u003d\"true\" class\u003d\"statText\"\u003e2)\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e{\"####\",\n \"#..#\",\n \"#..#\",\n \"####\"}\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003eReturns: 0\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003eYou cannot win any game on this board, as you cannot make any coin fall off the board.\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" nowrap\u003d\"true\" class\u003d\"statText\"\u003e3)\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e{\"#.#.#\"}\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003eReturns: 0\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" nowrap\u003d\"true\" class\u003d\"statText\"\u003e4)\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e{\"........\",\n \"........\",\n \"........\",\n \"........\",\n \"........\",\n \"........\",\n \"........\",\n \"........\"}\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003eReturns: 688856388\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003chr\u003e\u003cp\u003eThis problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved. \u003c/p\u003e\n \n "}}]}