A698.[USACO 2015 February Bronze]Cow Hopscotch
普及-
通过率:0%
时间限制:1.00s
内存限制:128MB
题目描述
Just like humans enjoy playing the game of Hopscotch, Farmer John's cows have invented a variant of the game for themselves to play. Being played by clumsy animals weighing nearly a ton, Cow Hopscotch almost always ends in disaster, but this has surprisingly not deterred the cows from attempting to play nearly every afternoon.
The game is played on an R by C grid (2 <= R <= 15, 2 <= C <= 15), where each square is colored either red or blue. Cows start in the top-left square and move to the bottom-right square by a sequence of jumps, where a jump is valid if and only if
-
You are jumping to a square of a different color,
-
The square that you are jumping to is at least one row below the current square that you are on, and
-
The square that you are jumping to is at least one column to the right of the current square that you are on.
Please help the cows compute the number of different possible sequences of valid jumps that will take them from the top-left square to the bottom-right square.
INPUT FORMAT:
The first line contains the two integers R and C. The next R lines will each contain C characters. Each character is either 'R' or a 'B', indicating a red square or a blue square.
OUTPUT FORMAT:
Output the number of different ways one can jump from the top-left square to the bottom-right square.
就像人类喜欢玩跳房子游戏一样,农夫约翰的牛发明了这种游戏的变体来玩。由体重接近一吨的笨拙动物玩的“牛跳房子”游戏几乎总是以灾难告终,但令人惊讶的是,这并没有阻止奶牛每天下午玩耍。
游戏是在R∗C网格(2<=R<=15,2<=C<=15)上进行的,每个方格都是红色或蓝色的。奶牛从左上角的方块开始,通过一系列的跳跃移动到右下角的方块,一次跳跃是有效的当且仅当
1)你跳到一个不同颜色的正方形,
2)你要跳到的方块至少比你当前所在的方块低一行,并且
3)你要跳到的方块至少在你当前所在方块的右边一列。
请帮助牛计算从左上角方格到右下角方格的不同的有效跳跃序列的数量。
输入格式
第一行包含两个整数R和C。接下来R行每行包含C字符。每个字符要么是“R”,要么是“B”,表示红色方块或蓝色方块。
输出格式
输出从左上角方块跳到右下角方块的不同方式的数量。
输入输出样例
输入#1
4 4 RRRR RRBR RBBR RRRR
输出#1
3