2 shunfurh shunfurh 于 2017.09.02 23:17 提问

DomiNo Grid

Dominoes are small, flat, rectangular-shaped game pieces. Domino pieces are usually twice as long as they are wide and are usually made to be exactly half as thick as they are wide so that they can stand on edge without falling over. If we push one end of a queue of dominoes, the whole queue will fall over.

Now, you will be given some descriptions of domino grid with a '.' indicating an open space and an uppercase 'X' indicating a domino and the force used on one domino. You are to compute the ending descriptions. The force consists of two parts : location and direction. There are 8 directions shown below.

direction abbreviation
West : W
NorthWest : V
North : N
NorthEast : Y
East : E
SouthEast : Q
South : S
SouthWest : J
The falling direction of the pushed domino is always the same as the force. Other dominoes will fall over if: 1) it's adjacent with a previous fallen domino. 2) it's within 45 degree of the falling direction of the previous domino.

The direction of falling is the relative position of it to the previous fallen domino. No two dominoes will cause the same domino to fall over simultaneously. See the following example for more details.

XXX
XXX
XXX
We say the outer 8 dominoes are adjacent with the middle one. With a force to east on the middle domino, the 3 dominoes in the third column will fall over and the direction will be northeast, east, southeast. So the ending grid is :

XXY
XEE
XXQ
Input

There are multiple test cases. Each case begins with a line containing two positive integer n and m (1 <= n, m <= 500) that are the number of rows and columns of the grid. The next n lines each with m chars (only '.' and 'X') describe one row of the grid. At last, two integers i, j (ith row, jth column, both i and j start from 1) indicate the location of the force and a char C describes the direction of the force. You can assume that there is a domino at the location (i, j).

Process to the end of file.

Output

Print the ending description of the grid, using the abbreviations for the fallen dominoes.

Print a blank line between cases.

Sample Input

2 4
..XX
XX..
1 3 S
4 4
XXX.
...X
X..X
XXX.
3 1 E
Sample Output

..SX
WJ..

WWV.
...N
E..Y
XQE.

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.17 22:42
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
dojo grid 组件
dojo的grid组件,其功能还是很强大的,我主要用到两种方式: Test dojox.grid.DataGrid Basic Editing @import "../../../dojo/resources/dojo.css"; @import "../r
ZOJ 2994 && HDU 1992 Tiling a Grid With Dominoes (状压DP)
题目链接:HDU 1992 Tiling a Grid With Dominoes 题意:一个4*N的矩形,用1*2的小矩形铺满的方法数是多少。 思路:4*N。只有4行想到状压,dp[i][j]表示前i行状态j的方法数,影响当前行的只有上一行!0成对出现表示横着放,1表示竖着放,所以第一行的状态0.3.9.12.15五种,并且只要上一行是0状态。当前行的状态就为0.3.9.12.15五种可能。
ZOJ 2925 DomiNo Grid
广搜。。深搜是不行的。。 深搜和广搜搜索的顺序不一样。。 一开始 深搜 wa死了 #include #include #include #include #include #include #include #include #include using namespace std; #define inf 0x3f3f3f3f #define eps 1e-8 #define LL lon
DomiNo Grid做题记录
D - DomiNo Grid Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %lld Description Dominoes are small, flat, rectangular-shaped game pieces. Domino pieces are usually tw
zju 2529 DomiNo Grid
简单提,只有广搜可以过#include iostream>#include string>#include queue>using namespace std;typedef struct  ...{    int x, y;    char c;}Node;int m, n;char a[501][501];int d[8][3][2] = ...{        ...{...{-1,
ZOJ2925 DomiNo Grid(广搜)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2925 DomiNo Grid Time Limit: 2 Seconds      Memory Limit: 65536 KB Dominoes are small, flat, rectangular-shaped game pi
在Domino中配置servlet
因为需要从domino中抽取附件,将下载方式改为使用domino中自带的servlet方式下载:
Domino R8+版本编写及调用webservice
【背景】 随着web系统业务的深入开发,与第三方系统集成的需求越来越多,系统之间集成的方法也比较多,如通过jdbc、odbc直接与关系数据库进行增、删、改操作,本文主要介绍通过webservice与第三方系统集成方法。   【基础要求】          1、Webservice提供者(designer7叫web服务)          domino服
websphere与domino之间配置sso
was与domino需要共享一个用户注册表,domino不支持自定义的用户注册表一。domino方面    配置并启动Lotus Domino的LDAP服务配置并启动Lotus Domino的LDAP服务n        域:mycompany.comn        LDAP域名:ldap.mycompany.comn        LDAP的Base DN:dc=myc
domino中java代理导致内存溢出问题的解决方法
环境:DOMINO6.02    主机:as400-820  我用JAVA写了一个代理,编译和运行均正常。但此代理运行几百次后,就会报错:java.lang.OutOfMemoryError,估计是内存溢出错误。我的程序中已对内存做了清理,代码如下:  sysdoc.recycle();  sysview.recycle();  view.recycle();  doc.recycle();  d