Crashing Robots
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 7880 | Accepted: 3429 |
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.
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
The first line of input is K, the number of test cases. Each test case starts with one line consisting of two integers, 1 <= A, B <= 100, giving the size of the warehouse in meters. A is the length in the EW-direction, and B in the NS-direction.
The second line contains two integers, 1 <= N, M <= 100, denoting the numbers of robots and instructions respectively.
Then follow N lines with two integers, 1 <= Xi <= A, 1 <= Yi <= B and one letter (N, S, E or W), giving the starting position and direction of each robot, in order from 1 through N. No two robots start at the same position.
Figure 1: The starting positions of the robots in the sample warehouse
Finally there are M lines, giving the instructions in sequential order.
An instruction has the following format:
< robot #> < action> < repeat>
Where is one of
and 1 <= < repeat> <= 100 is the number of times the robot should perform this single move.
The second line contains two integers, 1 <= N, M <= 100, denoting the numbers of robots and instructions respectively.
Then follow N lines with two integers, 1 <= Xi <= A, 1 <= Yi <= B and one letter (N, S, E or W), giving the starting position and direction of each robot, in order from 1 through N. No two robots start at the same position.
![](https://i-blog.csdnimg.cn/blog_migrate/5c7adf6dcd1e44166dc55094bc35f881.jpeg)
Figure 1: The starting positions of the robots in the sample warehouse
Finally there are M lines, giving the instructions in sequential order.
An instruction has the following format:
< robot #> < action> < repeat>
Where is one of
- L: turn left 90 degrees,
- R: turn right 90 degrees, or
- F: move forward one meter,
and 1 <= < repeat> <= 100 is the number of times the robot should perform this single move.
Output
Output one line for each test case:
Only the first crash is to be reported.
- 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
4 5 4 2 2 1 1 E 5 4 W 1 F 7 2 F 7 5 4 2 4 1 1 E 5 4 W 1 F 3 2 F 1 1 L 1 1 F 3 5 4 2 2 1 1 E 5 4 W 1 L 96 1 F 2 5 4 2 3 1 1 E 5 4 W 1 F 4 1 L 1 1 F 20
Sample Output
Robot 1 crashes into the wall Robot 1 crashes into robot 2 OK Robot 1 crashes into robot 2
Source
题意:一个n*m的地图中,有若干个机器人,经过若干步操作,若机器人没有发生碰撞或者走出地图(就是碰到地图的边界)就输出OK,如果机器人走出地图输出"Robot 1 crashes into the wall"其中1为走出边界的机器人的编号;如果两个机器人相撞则输出"Robot 1 crashes into robot 2"表示机器人1撞了机器人2.
输入:第一行为T;代表有T组数据,第二行有两个数,代表地图的大小n*m,第三行有两个数,分别代表机器人的数量nn和操作指令的数目mm。4到nn+4行代表nn个机器人的位置和行动的方向。nn+5行到nn+5+m为操作指令。输入结束。
注意:并不是所有的机器人同时行动,而是根据操作指令一步一步的进行。另外地图和平时敲代码所使用的地图不大一样,横纵坐标颠倒了。很不适应......
关于地图:因为地图和平时写的有很大的差别,所以写的时候迷糊了一阵。其实
地图的使用是在查找机器人编号和判断机器人是否出界时。因为题目给的地图横纵坐标颠倒所以写代码时也应该进行颠倒。注意了这些其他的都是小问题了。
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int map[101][101];
int n,m;
int nn,mm;
int a[10100];
char aa[11000];
///1为向东,4为向南,3为向西,2为向北
struct node
{
int x,y,z;
} qq;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int tt;
int flag = 0;
memset(map,0,sizeof(map));
memset(a,0,sizeof(a));
scanf("%d%d",&m,&n);
if(n > m)
{
tt = n;
}
else
{
tt = m;
}
scanf("%d%d",&nn,&mm);
char str[10];
int x,y;
for(int i=1; i<=nn; i++)
{
scanf("%d%d%s",&x,&y,str);
map[y][x] = i;
if(str[0] == 'E')
{
a[i] = 1;
}
else if(str[0] == 'W')
{
a[i] = 3;
}
else if(str[0] == 'S')
{
a[i] = 4;
}
else if(str[0] == 'N')
{
a[i] = 2;
}
}
for(int kk=1; kk<=mm; kk++)
{
scanf("%d%s%d",&x,&str,&y);
if(str[0] == 'R')
{
y = y % 4;
a[x] = a[x] - y;
if(a[x]<=0)
{
a[x] = 4 + a[x];
}
}
else if(str[0] == 'L')
{
y = y % 4;
a[x] = a[x] + y;
if(a[x]>4)
{
a[x] = a[x] - 4;
}
}
else if(str[0] == 'F')
{
int ii,jj;
for(int i=1; i<=tt; i++)
{
for(int j=1; j<=tt; j++)
{
if(map[i][j] == x)
{
ii = i;
jj = j;
break;
}
}
}
if(a[x] == 1 && flag == 0)
{
int ff = 0;
for(int i=1; i<=y; i++)
{
if(jj+i>m)
{
qq.z = 1;
qq.x = x;
ff = 1;
flag = 1;
break;
}
else if(map[ii][jj+i]!=0 && jj+i<=m)
{
qq.z = 2;
qq.x = x;
qq.y = map[ii][jj+i];
ff = 1;
flag = 1;
break;
}
}
map[ii][jj] = 0;
if(ff == 0)
{
map[ii][jj+y] = x;
}
}
else if(a[x] == 2 && flag == 0)
{
int ff = 0;
for(int i=1; i<=y; i++)
{
if(ii+i >n)
{
qq.z = 1;
qq.x = x;
flag = 1;
ff = 1;
break;
}
else if(map[ii+i][jj]!=0 && ii+i<=n)
{
qq.z = 2;
qq.x = x;
qq.y = map[ii+i][jj];
ff = 1;
flag = 1;
break;
}
}
map[ii][jj] = 0;
if(ff == 0)
{
map[ii+y][jj] = x;
}
}
else if(a[x] == 3 && flag == 0)
{
int ff = 0;
for(int i=1; i<=y; i++)
{
if(jj-i <=0)
{
qq.z = 1;
qq.x = x;
flag = 1;
ff = 1;
break;
}
else if(map[ii][jj-i]!=0 && jj-i>0)
{
qq.z = 2;
qq.x = x;
qq.y = map[ii][jj-i];
ff = 1;
flag = 1;
break;
}
}
map[ii][jj] = 0;
if(ff == 0)
{
map[ii][jj-y] = x;
}
}
else if(a[x]==4 && flag == 0)
{
int ff = 0;
for(int i=1; i<=y; i++)
{
if(ii-i<=0)
{
qq.z = 1;
qq.x = x;
ff = 1;
flag = 1;
break;
}
else if(map[ii-i][jj]!=0 && ii-i>0)
{
qq.z = 2;
qq.x = x;
qq.y = map[ii-i][jj];
ff = 1;
flag = 1;
break;
}
}
map[ii][jj] = 0;
if(ff == 0)
{
map[ii-y][jj] = x;
}
}
}
}
if(flag == 0)
{
printf("OK\n");
}
else if(flag == 1 && qq.z == 1)
{
printf("Robot %d crashes into the wall\n",qq.x);
}
else if(flag == 1 && qq.z == 2)
{
printf("Robot %d crashes into robot %d\n",qq.x,qq.y);
}
}
return 0;
}
现给出一些测试数据:
32 1 1 1 1 1 1 W 1 F 1 3 3 1 9 2 2 W 1 F 1 1 L 1 1 F 1 1 L 1 1 F 2 1 L 5 1 F 2 1 R 3 1 F 2 5 5 9 1 3 1 W 3 2 N 3 4 S 3 5 E 1 3 S 2 3 N 4 3 E 5 4 W 3 3 W 9 F 4 5 5 9 1 3 1 W 3 2 N 3 4 S 3 5 E 1 3 S 2 3 N 4 3 E 5 4 W 3 3 S 9 F 4 5 5 9 1 3 1 W 3 2 N 3 4 S 3 5 E 1 3 S 2 3 N 4 3 E 5 4 W 3 3 N 9 F 4 5 5 9 1 3 1 W 3 2 N 3 4 S 3 5 E 1 3 S 2 3 N 4 3 E 5 4 W 3 3 E 9 F 4 5 5 2 3 3 3 E 4 5 N 2 L 3 2 R 8 2 F 3 46 46 9 100 39 25 E 15 14 N 15 22 N 27 25 S 25 40 S 19 36 W 27 6 W 22 45 W 28 15 W 5 F 13 3 R 2 8 F 9 5 L 4 6 F 7 3 F 12 9 F 5 6 L 2 3 L 2 3 F 13 2 L 2 4 F 12 9 L 2 9 F 2 5 F 1 3 F 3 9 L 2 3 L 5 3 L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 N 28 5 E 29 6 E 10 3 W 7 6 N 6 5 N 13 2 S 10 5 W 5 F 4 3 R 22 11 R 13 5 L 2 6 F 1 9 F 1 3 F 8 15 F 2 3 F 1 11 L 2 6 R 2 4 41 2 100 1 37 S 2 10 W 1 R 2 2 F 3 1 R 2 1 F 2 2 R 2 1 F 3 2 R 2 1 F 1 2 L 23 2 L 13 2 R 30 1 F 1 1 L 2 2 F 4 1 R 28 2 R 18 1 F 1 1 F 6 2 F 6 2 F 6 1 L 2 1 F 3 1 R 2 2 F 6 2 L 26 2 L 2 1 R 19 2 L 2 2 F 1 2 R 30 2 F 1 2 F 1 2 F 1 2 L 19 2 R 2 2 F 2 1 F 3 1 L 21 2 F 6 1 L 15 2 R 30 1 F 1 1 L 26 1 L 2 2 F 6 2 L 1 1 F 7 2 L 17 1 F 1 1 L 21 1 F 6 2 L 26 1 F 2 1 F 7 2 L 2 2 R 20 2 R 27 2 F 3 1 F 6 1 L 6 2 R 9 1 F 6 1 L 2 1 F 1 2 F 4 2 R 2 2 L 2 2 R 2 1 F 3 2 R 2 1 R 2 1 R 5 1 F 4 2 L 14 1 F 1 2 R 24 1 R 2 2 L 13 2 F 2 2 F 4 1 F 4 1 R 9 2 F 4 2 L 29 2 F 5 1 F 3 2 F 4 1 R 7 2 R 2 1 L 2 1 R 25 1 R 20 2 L 25 1 R 28 1 R 2 1 F 6 1 L 2 1 F 4 1 R 20 2 L 15 3 20 2 1 2 14 N 2 13 W 2 F 2 42 27 19 1 19 25 E 24 20 S 14 3 E 41 3 N 3 18 W 30 2 E 8 24 N 35 13 E 20 7 S 32 23 E 29 1 W 1 14 E 39 7 E 1 12 E 10 4 E 19 18 W 28 6 E 29 21 W 7 13 W 12 F 1 29 44 52 10 28 29 E 25 31 S 22 31 N 5 2 E 16 28 E 19 2 W 5 4 S 22 38 S 6 37 E 2 25 N 17 19 N 4 6 S 8 25 N 13 22 N 4 11 N 5 39 S 18 34 S 17 1 W 11 17 N 14 34 W 13 31 W 26 1 S 12 38 E 14 21 W 2 2 S 23 20 S 24 14 S 5 29 E 2 10 W 26 24 W 24 34 N 17 38 E 17 29 N 20 26 S 10 7 N 19 8 N 27 7 W 5 5 W 4 39 S 27 32 S 25 12 S 28 25 S 18 31 W 15 41 S 20 20 E 6 22 W 9 12 W 24 2 E 19 32 N 23 34 S 17 11 W 6 4 S 46 L 2 43 F 4 47 F 2 33 F 5 36 L 11 3 L 2 45 L 2 40 F 5 33 F 10 45 F 6 27 37 46 100 20 22 S 26 3 N 22 28 S 17 16 W 15 18 N 11 17 S 7 15 W 17 2 E 7 16 W 13 14 S 11 27 N 21 23 S 11 12 E 22 11 S 19 11 E 22 1 S 8 16 S 21 18 S 2 20 W 16 6 S 5 22 N 3 15 S 2 29 W 14 23 S 19 9 W 12 30 N 3 28 N 23 33 S 25 24 N 6 4 S 12 6 N 1 14 N 24 1 E 8 21 W 23 22 W 10 21 N 17 31 S 7 11 S 13 7 E 6 27 S 3 6 W 12 35 E 23 16 E 5 29 W 20 23 S 1 22 E 3 L 2 25 R 25 33 R 5 24 F 9 25 F 2 15 F 2 46 L 4 46 L 13 45 L 14 26 F 4 4 F 5 42 F 1 39 R 3 24 L 2 6 F 2 46 F 5 12 F 8 6 F 3 9 F 5 36 F 5 38 R 2 35 L 30 38 F 7 2 R 6 46 L 3 21 R 2 44 F 1 36 F 2 23 F 1 40 R 30 11 F 3 20 L 6 10 F 6 10 R 20 11 F 1 35 L 29 27 F 8 3 L 24 14 L 6 32 F 10 40 F 8 26 R 3 12 F 5 10 L 19 10 L 2 36 R 2 27 F 1 21 L 2 39 F 1 17 F 7 46 L 25 2 L 13 5 R 2 2 R 18 22 F 9 45 L 18 16 F 6 5 F 9 34 F 1 5 L 2 21 F 6 36 L 26 41 F 6 2 F 1 5 F 8 38 F 5 35 F 9 15 R 2 31 F 2 37 L 2 44 F 2 46 F 1 40 F 1 42 F 4 12 F 9 22 F 2 7 R 2 9 R 24 17 F 6 15 R 2 34 F 5 46 F 6 29 R 2 9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 2 5 F 4 7 F 4 33 26 40 100 9 16 E 1 14 N 13 23 W 3 6 W 6 20 S 4 21 E 12 25 E 5 23 S 24 4 W 20 3 E 17 7 N 8 22 S 6 12 W 1 16 N 32 22 E 15 1 E 4 14 S 17 19 S 1 4 W 26 9 E 24 24 E 14 10 E 1 17 S 10 20 N 31 8 N 15 5 E 24 20 E 27 13 E 9 7 N 30 20 W 21 4 S 27 5 N 26 15 W 32 7 E 18 21 W 21 19 N 6 18 W 9 4 W 13 1 E 2 8 S 36 R 2 39 F 1 3 F 5 35 L 2 30 F 9 29 L 2 3 L 2 26 F 5 14 L 10 24 F 9 9 L 24 17 F 5 23 F 2 23 F 4 34 F 2 18 F 4 15 F 1 17 F 7 39 L 6 32 F 1 7 F 6 38 R 2 19 L 6 2 R 2 5 F 1 10 F 5 4 L 2 38 F 3 2 F 8 37 R 2 6 L 13 5 F 2 13 F 5 1 F 9 33 F 6 20 F 3 12 F 1 21 L 27 22 F 9 21 F 3 32 L 16 28 F 1 29 L 7 15 F 1 12 F 8 23 F 8 33 F 5 9 F 4 14 R 11 38 F 7 16 L 2 18 R 4 27 F 7 40 R 8 23 F 1 11 L 31 39 F 6 24 F 4 23 F 1 12 F 7 19 F 6 14 F 5 7 L 2 27 R 2 11 F 9 27 L 4 38 F 7 4 L 8 29 F 2 29 L 31 33 F 4 33 F 9 7 F 7 11 F 6 14 F 1 25 F 9 6 R 5 8 R 2 32 R 2 34 R 2 19 L 20 27 L 5 16 R 28 18 F 9 20 F 3 21 L 2 39 F 4 31 F 3 16 F 2 19 R 2 31 F 4 38 F 1 28 R 2 33 F 1 8 F 5 37 R 18 8 L 8 15 R 2 22 F 8 2 R 2 14 26 2 1 13 24 W 4 13 E 1 L 2 30 35 11 100 10 8 S 19 3 E 22 7 N 17 32 E 19 4 N 8 4 E 26 23 S 11 14 N 21 30 N 8 1 S 21 3 S 1 R 28 2 F 2 10 F 7 6 R 2 8 F 2 4 F 6 4 R 2 4 F 1 1 F 10 1 L 2 6 F 7 10 R 27 3 L 2 7 F 2 5 F 1 8 F 1 1 R 2 1 L 2 11 F 8 3 F 2 7 R 2 10 R 2 4 L 30 3 F 1 3 F 5 10 F 5 6 R 2 4 F 1 6 L 27 4 F 7 8 R 17 9 F 10 1 L 20 1 F 6 4 F 1 11 R 26 3 F 2 1 F 6 4 F 1 10 F 1 8 F 1 8 R 13 7 F 2 1 F 2 8 L 24 5 F 8 11 F 1 6 F 1 11 R 2 3 R 2 3 F 6 3 R 11 5 F 8 10 F 6 11 L 2 11 L 2 4 F 9 4 R 23 5 F 6 1 R 2 10 F 8 1 L 2 4 L 31 7 L 2 5 F 3 4 F 7 2 L 6 4 R 1 10 R 24 8 F 10 2 R 12 7 F 4 4 L 2 1 F 1 8 F 1 5 L 24 1 L 2 3 F 1 4 L 14 10 L 2 11 F 3 3 F 1 2 L 2 5 F 2 4 R 2 11 F 3 11 F 6 8 F 9 5 L 2 6 F 9 10 F 8 2 F 1 1 F 7 1 L 20 8 F 6 1 R 2 3 F 3 11 R 2 1 R 16 3 F 9 19 8 2 2 14 1 W 12 7 E 2 F 4 2 F 1 27 32 2 6 21 23 E 10 16 E 2 F 1 2 F 3 1 F 4 2 F 6 1 L 15 1 F 7 24 39 29 1 22 22 W 5 5 N 6 1 S 8 29 N 12 30 N 14 34 S 4 21 E 3 28 N 15 9 E 1 12 E 20 1 W 15 27 N 23 1 N 20 36 E 19 1 S 2 32 N 9 5 N 4 37 S 17 6 N 11 23 S 18 36 N 9 11 N 12 35 W 12 21 S 1 5 W 5 17 E 4 3 E 17 9 E 5 19 W 12 L 4 90 24 100 21 24 24 N 13 7 S 65 22 S 57 20 N 62 8 W 34 21 S 70 23 W 58 19 W 26 17 S 23 4 E 56 12 N 21 18 S 23 21 S 24 19 S 36 11 S 25 5 N 9 17 N 36 1 E 21 17 E 71 11 E 89 20 W 75 15 E 84 12 S 80 8 W 46 16 E 6 9 N 89 9 W 14 20 E 31 1 W 66 13 E 2 6 W 69 24 W 78 15 E 5 4 N 11 11 N 16 15 E 50 10 S 2 19 W 88 11 N 46 4 W 23 3 S 42 18 S 84 14 E 10 5 N 25 7 W 4 24 E 23 6 E 44 2 E 43 19 E 46 20 E 48 11 E 37 22 N 35 1 W 57 8 W 56 6 W 24 5 W 12 16 W 72 6 W 62 6 W 83 4 N 38 12 S 59 7 S 87 2 N 56 8 S 78 8 S 90 18 N 13 17 S 62 11 S 81 17 W 65 2 S 90 11 W 82 17 E 78 7 S 79 23 W 57 18 W 64 23 E 49 14 S 58 18 S 53 9 N 5 3 S 81 18 N 38 5 S 59 1 E 56 21 S 9 6 S 61 24 W 25 10 S 19 21 E 57 13 N 37 7 E 35 18 N 83 7 N 30 10 N 86 3 W 29 6 N 5 6 S 5 14 W 42 8 S 50 1 N 30 6 S 38 R 9 49 F 5 35 L 17 18 R 25 1 R 2 72 R 19 3 L 2 42 R 2 43 R 2 61 F 10 23 F 7 96 L 31 49 F 3 58 F 18 54 F 9 43 F 15 61 R 2 84 F 8 16 F 1 6 R 2 95 R 2 98 27 100 100 22 27 N 57 13 E 46 16 E 73 27 S 42 14 E 26 17 W 69 22 E 28 3 N 11 19 E 21 3 W 58 8 E 6 20 N 19 7 E 25 15 E 63 26 S 96 27 N 38 9 N 10 19 W 67 12 N 73 24 E 38 15 W 14 21 E 22 10 E 48 3 S 22 13 N 7 12 W 85 12 W 29 13 E 64 23 E 6 23 E 77 3 W 53 18 E 45 26 N 9 22 W 77 7 S 7 21 W 65 19 N 62 22 W 31 25 W 72 20 S 34 5 E 8 26 E 98 10 S 74 4 N 29 17 W 48 5 E 42 26 S 13 21 S 83 16 N 56 21 W 87 11 S 65 13 W 8 5 W 68 8 W 62 7 E 50 23 N 61 24 S 48 4 N 62 24 E 79 1 W 64 7 N 63 6 N 16 14 E 76 8 N 29 18 N 16 12 E 5 19 W 77 11 N 44 25 S 36 21 W 85 25 W 16 11 N 71 9 S 27 13 S 43 9 W 87 3 N 11 5 N 49 8 W 82 6 E 36 3 N 38 14 S 41 25 S 72 2 W 98 6 E 16 4 E 31 21 W 78 8 W 75 21 N 4 21 W 48 14 W 62 13 N 27 11 W 79 21 S 45 13 E 31 15 S 26 14 E 31 9 W 10 2 N 38 27 W 57 7 S 19 L 29 42 F 1 56 R 2 44 F 1 90 R 19 53 R 6 52 R 2 16 R 30 34 R 28 78 F 6 1 F 4 12 F 2 41 R 2 24 L 2 71 F 17 10 F 12 52 L 2 83 F 10 37 F 14 49 L 27 25 F 16 71 F 5 44 L 2 50 R 26 94 F 3 15 F 1 73 F 11 34 F 3 91 L 26 19 L 2 25 L 2 46 R 2 84 L 18 3 F 12 44 L 2 11 F 8 48 L 2 73 L 30 74 L 2 19 L 2 54 R 23 9 F 6 49 F 11 78 L 2 56 R 2 36 R 19 57 F 6 2 F 5 88 L 29 33 L 27 37 R 2 88 F 16 61 F 18 53 R 2 13 R 8 100 L 28 20 L 2 49 F 13 48 F 10 4 L 15 45 F 1 1 F 7 68 L 2 30 L 6 80 R 10 44 F 1 73 F 16 82 L 2 62 L 2 94 L 10 4 F 5 86 F 18 43 L 9 99 F 4 97 F 7 100 L 2 61 F 17 70 R 2 20 F 9 70 F 5 34 F 17 43 R 8 15 F 11 24 F 15 25 F 20 78 F 10 43 R 19 96 R 2 95 R 15 50 F 9 55 F 13 1 F 17 87 R 2 86 L 25 69 L 2 74 R 26 6 L 7 77 F 9 49 F 8 12 R 6 79 61 100 100 69 58 S 8 37 N 30 10 E 75 23 S 9 58 N 35 46 N 6 50 S 36 22 W 5 28 S 42 32 E 72 41 N 73 8 W 65 46 S 11 23 E 3 42 S 35 17 S 36 30 N 48 17 S 33 44 W 7 22 W 62 54 E 17 43 S 37 17 E 74 7 S 44 15 N 65 13 N 41 17 S 15 21 N 51 46 E 50 10 E 29 30 W 40 60 W 27 24 S 10 13 E 21 45 S 36 54 E 54 41 W 39 6 S 45 47 W 63 34 S 12 31 S 56 43 S 51 54 W 42 7 N 72 45 W 63 24 W 50 38 S 53 21 N 55 36 S 54 60 S 71 44 N 44 55 N 68 48 W 2 47 W 12 37 N 17 57 E 51 61 N 55 8 N 18 21 N 78 36 E 61 27 W 7 27 N 37 9 S 13 29 W 49 12 W 67 61 S 78 3 S 58 31 S 51 4 W 77 29 W 42 22 S 45 43 S 9 6 W 63 11 S 31 21 N 78 42 E 39 13 S 16 2 N 56 58 S 68 25 W 72 6 W 57 51 W 40 42 E 31 7 E 69 11 S 60 22 N 56 44 S 59 13 W 3 53 N 54 44 N 70 51 N 58 50 N 32 32 W 17 16 E 63 13 E 37 51 N 22 29 E 27 60 S 2 18 E 20 59 S 71 F 15 25 R 8 8 F 17 26 R 30 72 F 20 22 R 2 92 R 31 12 F 19 35 L 2 72 F 5 55 F 19 37 F 14 91 L 18 8 L 31 91 F 5 92 L 2 40 L 1 90 F 1 5 F 8 63 R 22 67 R 5 70 F 21 84 F 1 90 L 2 80 L 2 74 F 19 52 F 18 55 L 18 50 L 2 60 F 17 26 F 4 51 F 23 65 F 9 13 F 7 5 R 2 61 R 2 30 F 8 24 F 19 6 L 2 51 F 9 19 R 25 58 F 22 62 R 5 93 L 5 58 R 2 69 L 2 84 L 2 55 L 31 91 F 6 69 L 29 62 F 6 67 F 3 64 R 2 1 R 30 90 F 9 8 L 2 15 R 2 46 R 27 45 F 11 86 F 10 34 R 2 66 F 19 63 F 4 94 L 19 25 F 12 30 L 2 86 L 27 34 F 1 31 F 9 70 L 31 72 L 30 10 F 2 88 L 2 13 F 10 80 F 14 19 L 25 77 R 2 72 F 13 44 R 31 25 F 8 27 R 1 19 F 21 88 F 19 79 F 5 49 F 11 63 L 22 91 L 30 30 F 19 40 R 2 18 L 2 88 L 2 28 R 3 27 R 2 82 F 1 14 F 1 100 R 2 46 F 5 2 R 2 70 L 25 23 F 16 20 90 73 4 5 88 N 10 9 N 4 28 W 10 36 E 4 88 W 4 68 S 3 2 S 12 44 E 4 84 W 14 48 E 1 7 S 12 84 S 8 2 N 18 44 S 2 80 S 18 15 N 12 58 W 7 34 S 19 64 E 9 20 W 18 81 S 4 30 S 10 21 W 14 18 N 11 90 N 18 17 S 14 69 W 10 16 N 12 81 W 17 21 E 15 77 S 8 25 S 19 47 S 1 57 E 16 21 E 13 22 S 9 68 W 16 3 S 12 37 E 19 73 S 13 30 E 14 24 E 11 65 E 13 39 W 9 36 E 13 27 S 13 67 W 10 48 E 15 75 E 2 1 W 12 75 E 3 45 S 9 58 E 8 9 S 4 32 E 11 54 E 13 75 S 11 75 N 7 81 E 1 59 S 10 42 E 12 31 S 4 87 N 20 46 E 5 29 N 16 20 S 13 84 W 9 78 N 5 63 S 10 90 W 6 46 W 14 57 W 11 43 S 15 F 10 56 R 2 34 F 16 39 F 10 100 100 100 100 42 58 S 49 6 N 40 70 W 8 97 N 57 65 S 85 68 E 75 45 E 17 59 N 43 40 W 2 84 W 14 96 E 12 7 W 10 26 N 48 41 N 82 73 N 53 39 N 49 87 W 96 43 W 4 11 E 63 72 W 45 58 N 23 20 W 69 77 W 15 49 N 61 8 E 47 90 E 88 11 W 60 26 S 89 25 E 11 9 N 62 61 E 62 60 N 93 32 N 59 30 E 38 64 N 14 46 W 74 2 N 47 40 N 72 87 S 58 17 E 97 89 E 68 6 W 82 20 W 73 85 E 61 75 N 42 9 N 45 96 E 84 94 N 26 36 S 44 63 W 35 52 E 97 67 E 98 22 W 2 16 W 88 36 S 86 92 W 67 39 W 4 82 N 48 61 S 23 7 W 41 4 N 98 38 E 65 36 N 48 16 N 61 11 N 52 30 S 16 46 E 54 75 N 42 63 W 37 79 W 29 50 N 81 58 S 42 32 S 60 75 E 6 56 W 82 9 W 23 96 N 95 26 E 62 18 S 54 1 N 87 89 W 26 79 N 20 20 N 91 56 W 6 74 W 57 9 N 25 12 N 39 58 S 57 2 W 33 21 N 69 59 N 10 23 W 26 7 E 25 76 S 74 12 W 87 40 E 7 97 W 50 81 S 78 63 N 51 96 N 34 F 12 77 F 4 75 F 3 5 L 27 17 F 8 77 R 2 87 F 30 8 F 5 95 F 13 17 L 12 70 R 2 45 F 15 44 R 27 76 L 59 91 F 9 89 L 2 67 F 27 76 F 7 73 F 10 73 F 8 15 R 27 47 F 5 49 L 16 82 R 2 15 F 10 56 F 2 40 F 26 37 L 26 7 R 2 19 L 2 42 F 1 76 F 2 37 L 3 73 R 14 5 R 2 67 F 25 15 R 2 64 F 1 61 L 2 16 L 21 89 R 2 37 F 12 80 R 29 96 R 11 90 F 20 44 R 3 46 F 3 56 L 2 36 L 2 95 L 16 45 R 2 75 F 2 22 R 27 71 F 6 22 L 7 27 F 3 90 F 5 10 F 1 88 R 2 24 L 29 91 R 14 21 L 22 91 F 9 46 L 2 82 R 3 50 R 2 76 R 11 47 L 2 96 L 4 34 F 9 72 F 27 35 L 28 96 F 17 21 F 16 55 F 22 89 L 17 60 R 26 7 F 22 23 R 20 16 R 31 62 L 12 60 L 2 8 L 1 29 R 10 58 F 18 36 F 8 55 F 7 4 F 2 69 L 23 76 L 2 31 F 21 29 F 3 14 L 2 94 R 2 34 L 27 21 L 2 78 L 7 4 R 2 9 F 29 78 F 16 output: Robot 1 crashes into the wall OK Robot 9 crashes into robot 6 Robot 9 crashes into robot 2 Robot 9 crashes into robot 3 Robot 9 crashes into robot 7 Robot 2 crashes into the wall Robot 3 crashes into robot 2 Robot 4 crashes into the wall Robot 12 crashes into the wall Robot 2 crashes into the wall Robot 3 crashes into the wall Robot 2 crashes into the wall Robot 2 crashes into the wall OK Robot 33 crashes into robot 32 Robot 25 crashes into robot 15 Robot 2 crashes into the wall Robot 3 crashes into the wall Robot 3 crashes into robot 2 Robot 1 crashes into the wall Robot 30 crashes into robot 27 OK Robot 2 crashes into robot 11 OK OK OK Robot 61 crashes into robot 82 Robot 1 crashes into the wall Robot 71 crashes into robot 44 Robot 34 crashes into robot 72 OK