shunfurh 于 2017.01.02 13:50 提问
A laserbox is a game involving some optical equipment. The game board is a square n×n grid. On each grid point, a gadget called a right-turner can be placed and several such gadgets are included. Finally, there is a ruby laser, and if the laser is mounted at the bottom end of a column, the beam will be directed northwards through that column. Analogously, the laser beam may be directed southwards from the top of a column, eastwards from the start of a row or westwards from the end of the row.
The game starts with some right-turners being spread out on some grid points and the laser (switched off) being mounted somewhere along the border of the rectangle. The player then tries to deduce where the beam will emerge when the laser is switched on. The effect of a right-turner is to deflect the beam ninety degrees to the right, regardless of from which of the four directions it enters.
Your program must do exactly what the player is supposed to do.
On the first line of the input is a single positive integer, telling the number of test cases to follow. The first line of each test case consists of two integers n r, where 1 ≤ n ≤ 50 is the size of the board and 1 ≤ r ≤ 50 the number of right-turners. The following r lines contain the coordinates x y of the right-turners. No two right-turners will have the same coordinates.
Finally, a line with two integers indicating the laser position follows. The bottom of column six is denoted by 6 0 and the start of row seven by 0 7. If the zeroes are replaced by n+1, the laser is placed at the top of column six and the end of row seven, respectively.
For each test case, output one line containing the coordinates X Y of the beam as it leaves the board. The same rules as for the laser apply, so X may equal 0 or n+1 or else Y equal 0 or n+1. If the beam gets caught and does not leave the board, the output should be 0 0.
- caozhy 2017.01.02 18:59
- sicily 1187. Laserbox
- 1187. Laserbox Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description A laserbox is a game involving some optical equipment. The game board is a square n×n grid. On each grid point,
- Sicily 1187. Laserbox
- 1187. Laserbox Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description A laserbox is a game involving some optical equipment. The game board is a square n×n grid. On each grid
- POJ 2766 laserbox 模拟还有过不了的map+set
- 题目大意： 第一行输入t表示有t组数据。 第二行输入n,r : n表示n*n的图，r表示右转灯个数。 接着输入r个右转灯坐标。 最后输入开始位置： (0,y)对应(1,y)，向E；(n+1,y)对应(n,y)，向W; (x,0)对应(x,1)，向N；(x,n+1)对应(x,n)，向S。思路： 自己想的是存好坐标然后用map