300467: CF89C. Chip Play

Memory Limit:256 MB Time Limit:4 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Chip Play

题意翻译

## 题目描述 有一个大小为n×m的矩形场,这个矩形场的某些地方有筹码,皆处于行与列上。 每个筹码上都有一个箭头。因此,场上的每个筹码都指向以下方向之一:上,下,左或右。 玩家可以选择一个筹码并开始行动。 以下是一次动作顺序: 1.所选筹码被标记为当前的筹码。 2.检查当前筹码的箭头指向方向的同一行(或同一列)的筹码。如果至少有一个,则将最近的筹码标记为新的当前筹码。 3.将先前的当前筹码从场中移除。 4.重复此过程。如果未找到新筹码,则将当前筹码从场地中移出,玩家的移动结束。 在移动结束时,玩家会获得分数,分数等于已移除筹码的数量。 要求找到最优的初始筹码安排,确定你在一次行动中可获得的最大分数并确定有几种方案能达成。 ## 输入格式 第一行包含两个整数n和m(1<=n,m,n×m<=5000 1 <= n,m,n×m <= 5000) 然后n行,每个行包含m个字符-这是地图的描述。 有三种字符 “。” 表示这个方块是空的。 “ L”,“ R”,“ U”,“ D”表示此处包含一个筹码,并且在其上的箭头分别表示左,右,上或下。 ## 输出格式 输出两个数字,一次行动之后可以获得的最大分数,以及达成最大积分的方案个数 ## 说明/提示 在第一个样例中,初始筹码在位置(3,3)(3,3),即可获得最大点数。 您可以在下图看到它的方案: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF89C/564cfdc234dcf38266b456e2e5fec700d68e459e.png) 其它方案将会有更差结果

题目描述

Let's consider the following game. We have a rectangular field $ n×m $ in size. Some squares of the field contain chips. Each chip has an arrow painted on it. Thus, each chip on the field points in one of the following directions: up, down, left or right. The player may choose a chip and make a move with it. The move is the following sequence of actions. The chosen chip is marked as the current one. After that the player checks whether there are more chips in the same row (or in the same column) with the current one that are pointed by the arrow on the current chip. If there is at least one chip then the closest of them is marked as the new current chip and the former current chip is removed from the field. After that the check is repeated. This process can be repeated several times. If a new chip is not found, then the current chip is removed from the field and the player's move ends. By the end of a move the player receives several points equal to the number of the deleted chips. By the given initial chip arrangement determine the maximum number of points that a player can receive during one move. Also determine the number of such moves.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ m $ ( $ 1<=n,m,n×m<=5000 $ ). Then follow $ n $ lines containing $ m $ characters each — that is the game field description. "." means that this square is empty. "L", "R", "U", "D" mean that this square contains a chip and an arrow on it says left, right, up or down correspondingly. It is guaranteed that a field has at least one chip.

输出格式


Print two numbers — the maximal number of points a player can get after a move and the number of moves that allow receiving this maximum number of points.

输入输出样例

输入样例 #1

4 4
DRLD
U.UL
.UUR
RDDL

输出样例 #1

10 1

输入样例 #2

3 5
.D...
RRRLL
.U...

输出样例 #2

6 2

说明

In the first sample the maximum number of points is earned by the chip in the position $ (3,3) $ . You can see its progress at the following picture: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF89C/564cfdc234dcf38266b456e2e5fec700d68e459e.png)All other chips earn fewer points.

Input

题意翻译

## 题目描述 有一个大小为n×m的矩形场,这个矩形场的某些地方有筹码,皆处于行与列上。 每个筹码上都有一个箭头。因此,场上的每个筹码都指向以下方向之一:上,下,左或右。 玩家可以选择一个筹码并开始行动。 以下是一次动作顺序: 1.所选筹码被标记为当前的筹码。 2.检查当前筹码的箭头指向方向的同一行(或同一列)的筹码。如果至少有一个,则将最近的筹码标记为新的当前筹码。 3.将先前的当前筹码从场中移除。 4.重复此过程。如果未找到新筹码,则将当前筹码从场地中移出,玩家的移动结束。 在移动结束时,玩家会获得分数,分数等于已移除筹码的数量。 要求找到最优的初始筹码安排,确定你在一次行动中可获得的最大分数并确定有几种方案能达成。 ## 输入格式 第一行包含两个整数n和m(1<=n,m,n×m<=5000 1 <= n,m,n×m <= 5000) 然后n行,每个行包含m个字符-这是地图的描述。 有三种字符 “。” 表示这个方块是空的。 “ L”,“ R”,“ U”,“ D”表示此处包含一个筹码,并且在其上的箭头分别表示左,右,上或下。 ## 输出格式 输出两个数字,一次行动之后可以获得的最大分数,以及达成最大积分的方案个数 ## 说明/提示 在第一个样例中,初始筹码在位置(3,3)(3,3),即可获得最大点数。 您可以在下图看到它的方案: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF89C/564cfdc234dcf38266b456e2e5fec700d68e459e.png) 其它方案将会有更差结果

加入题单

算法标签: