当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5516:Chessboard

题目描述
Ruirui and Doc are playing an interesting game on a chessboard with $n$ rows and $m$ columns. The rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. There are some broken grids on the chessboards, which a chess cannot move in. Firstly, Doc gives Ruirui a sequence of commands, each command is of one of four following forms:

$\cdot$Move Up: moving from grid $(x,y)$ to grid $(x-1,y)$;
$\cdot$Move Down: moving from grid $(x,y)$ to grid $(x+1,y)$;
$\cdot$Move Left: moving from grid $(x,y)$ to grid $(x,y-1)$;
$\cdot$Move Right: moving from grid $(x,y)$ to grid $(x,y+1)$.

Then Ruirui puts a single chess on a grid of the chessboard

Ruirui will move the chess by Doc's commands in sequence. If the chess will be out of boarder or in a broken grid after a move, she omits this command and \textbf{go on} to consider the next one until the last command. Now Ruirui wants to find the grid which the chess will be in the end.
输入解释
The first line contains a single integer $T~(1\le T\le 10)$, which indicates the number of test cases. Then $T$ test cases follow.

For each test case, the first line contains $4$ integers $n,m,o$ and $l~(1\le n,m,o,l\le 1000)$ representing the number of rows, the number of columns, the number of broken grids and the length of Doc's command sequence.

Next $o$ lines, each line contains two integers $i$ and $j$ describing the position of broken grid.

The last line contains Doc's command sequence, it's a string of length $l$ with each character being one of $\{``U",``D",``L",``R"\}$ denoting Move Up, Move Down, Move Left and Move Right respectively.
输出解释
For each test case, for each unbroken grid $(i,j)$, assume a chess started at $(i,j)$ would stop at $\left(x(i,j),y(i,j)\right)$, output the sum of $\left(i-x(i,j)\right)^2 + \left(j-y(i,j)\right)^2$ (over all unbroken $(i,j)$).
输入样例
2
5 5 5 5
2 3
5 1
5 5
4 4
3 5
RRRLR
10 10 10 10
2 6
3 8
7 2
5 3
4 3
3 2
7 9
6 8
9 10
10 6
DLLDRRURLR
输出样例
Case #1: 49
Case #2: 241
来自杭电HDUOJ的附加信息
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5516

最后修改于 2020-10-25T23:23:21+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000/10000MS(Java/Others) 131072/131072K(Java/Others)