编程介的小学生 2017-02-27 11:45 采纳率: 20.5%
浏览 982
已采纳

Chocobo World

Biko is a baby chocobo. One day, his friend Mog (a cat) disappreared while looking for treasure. Thus Biko started searching for Mog with Catanus (a cactus) and Moomba (a monkey-like animal). Though they were partners, Catanus and Moomba were only responsible for finding weapons and items every now and then, Biko had to adventure on his own.

Chocobo World is a SOLO-RPG��which means that the game can run automatically without being controled by players. Biko can walk, fight and sleep all by himself.

The game is played on a map of N*N grids which is shown by the above image in the middle. The point which blinks is where Biko is. The other points represent places of events. An event can be a battle, an item, a weapon or plot. Events that are touched off no longer exist. The game system employs the following method to make the game advance on it's own. The player first assign a value m to MOVE in the menu. Then every time Biko enters a grid, he first checks m grids ahead, to the left and to the right of himself. If there's no events in these grids, he will keep his direction. Or if there's any event(s) going on, Biko will turn to the direction where the nearest one is. If there are more than one possible choices, he will select by the priority order moving ahead > turning left > turning right. For example, in the map above, if m = 5��Biko's initial direction is to the right. He goes to right 3, up 3, right 1, down 2, etc.

Now given N,m,and places of l events, output the order that Biko touches them off.

Input

Input contains several tests. Each test has 3 intergers on its first line: N (N <= 100)��m (m >= 0) and l(l <= 1000). The jth of the following l lines contain the x, y coordinates of the jth event. The upper left corner is (1��1), x axis points down and y axis points right. Any two events do no overlap. The following line has 2 integers x0 and y0 (1 <= x0, y0 <= N) represents the initial positon of Biko, where there is always no events. Biko always faces east at the beginning. Input is terminated with N = m = l = 0.

Output

A line for each case,output the events Biko touched off in the order he did. Two adjacent numbers are seperated by a space. No spaces at the end of line.

P.S. The left side and the right side of the map are connected, so are the top border and the bottom border.

Sample Input

18 5 8
1 18
7 12
8 11
8 18
9 12
13 8
14 13
14 14
10 8
0 0 0

Sample Output

3 2 5 6 4 1 8 7

  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站