编程介的小学生 2017-03-07 05:51 采纳率: 20.5%
浏览 778
已采纳

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条回答 默认 最新

  • threenewbee 2017-03-13 00:03
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题