如何利用小游戏开发框架提升企业小程序的用户体验与运营效率
464
2022-11-09
POJ 2632 Crashing Robots (模拟)
Description
In a modernized warehouse, robots are used to fetch the goods. Careful planning is needed to ensure that the robots reach their destinations without crashing into each other. Of course, all warehouses are rectangular, and all robots occupy a circular floor space with a diameter of 1 meter. Assume there are N robots, numbered from 1 through N. You will get to know the position and orientation of each robot, and all the instructions, which are carefully (and mindlessly) followed by the robots. Instructions are processed in the order they come. No two robots move simultaneously; a robot always completes its move before the next one starts moving. A robot crashes with a wall if it attempts to move outside the area of the warehouse, and two robots crash with each other if they ever try to occupy the same spot.
Input
Output
Output one line for each test case: Robot i crashes into the wall, if robot i crashes into a wall. (A robot crashes into a wall if Xi = 0, Xi = A + 1, Yi = 0 or Yi = B + 1.) Robot i crashes into robot j, if robots i and j crash, and i is the moving robot. OK, if no crashing occurs.Only the first crash is to be reported.
Sample Input
45 42 21 1 E5 4 W1 F 72 F 75 42 41 1 E5 4 W1 F 32 F 11 L 11 F 35 42 21 1 E5 4 W1 L 961 F 25 42 31 1 E5 4 W1 F 41 L 11 F 20
Sample Output
Robot 1 crashes into the wallRobot 1 crashes into robot 2OKRobot 1 crashes into robot 2
题意
给出所有机器人的初始位置以及它的方向,然后对这些机器人进行操作,操作的方式有三种:左转、右转、前行,判断并输出在执行这些操作的时候机器人是否碰到墙(边界),或者是否与其他机器人相遇,若都没有,则输出 OK 。
思路
因为题目给出的数据范围很小,所以直接模拟便可,左转n次或者右转n次都相当于转动n%4次。
AC 代码
#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~