#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
int dir[5][2] = {{0,0},{0,1},{-1,0},{0,-1},{1,0}};
struct robot{
    int x,y;
    int face;
}r[105];//1 N ,3 S, 2 W, 4 E
int map[105][105];
int main(){
   int t,a,b,n,m;
    scanf("%d",&t);
    while(t--){
        memset(map,0,sizeof(map));
        scanf("%d%d",&a,&b);
       scanf("%d%d",&n,&m);
       char tmp;
        for (int i = 1; i <= n; i++)
       {
         scanf("%d %d %c",&r[i].x,&r[i].y,&tmp);
            map[r[i].x][r[i].y] = i;
          if(tmp == 'N')r[i].face = 1;
           else if(tmp == 'S')r[i].face = 3;
            else if(tmp == 'W')r[i].face = 2;
           else if(tmp == 'E')r[i].face = 4;
      }
        int ind,rep,flag = 0;
        for (int i = 1; i <= m; i++)
        {
            scanf("%d %c %d",&ind,&tmp,&rep);
            if(flag){continue;}
            if(tmp == 'L'){
                for (int k = 0; k < rep; k++)
                {
                    if(r[ind].face == 4)r[ind].face = 1;
                   else r[ind].face ++;
                }
           }else if(tmp == 'R'){
                for (int k = 0; k < rep; k++)
               {
                    if(r[ind].face == 1)r[ind].face = 4;
                    else r[ind].face --;
                }
           }
		   else if(tmp == 'F')
		   {
                map[r[ind].x][r[ind].y] = 0;
               for (int k = 0; k < rep; k++)
               {
                    r[ind].x += dir[r[ind].face][0];
                    r[ind].y += dir[r[ind].face][1];
                   if(r[ind].x < 1 || r[ind].x > a){flag = 1;break;}
                   if(r[ind].y < 1 || r[ind].y > b){flag = 1;break;}
                  if(map[r[ind].x][r[ind].y]!=0){
                        flag = 2;
                        printf("Robot %d crashes into robot %d\n",ind,map[r[ind].x][r[ind].y]);
                        break;
                   }
                }
               if(flag == 1)printf("Robot %d crashes into the wall\n",ind);
                if(flag == 0)map[r[ind].x][r[ind].y] = ind;
           }
        }
        if(flag == 0)printf("OK\n");
    }
    return 0;
}

POJ2632的更多相关文章

  1. POJ-2632 Crashing Robots模拟

    题目链接: https://vjudge.net/problem/POJ-2632 题目大意: 在一个a×b的仓库里有n个机器人,编号为1到n.现在给出每一个机器人的坐标和它所面朝的方向,以及m条指令 ...

  2. poj2632 Crashing Robots

    Crashing Robots Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9859   Accepted: 4209 D ...

  3. poj2632 模拟

    Crashing Robots Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8388   Accepted: 3631 D ...

  4. POJ2632——Crashing Robots

    Crashing Robots DescriptionIn a modernized warehouse, robots are used to fetch the goods. Careful pl ...

  5. POJ2632 Crashing Robots(模拟)

    题目链接. 分析: 虽说是简单的模拟,却调试了很长时间. 调试这么长时间总结来的经验: 1.坐标系要和题目建的一样,要不就会有各种麻烦. 2.在向前移动过程中碰到其他的机器人也不行,这个题目说啦:a ...

  6. poj2632 【模拟】

    In a modernized warehouse, robots are used to fetch the goods. Careful planning is needed to ensure ...

  7. 快速切题 poj2632

    Crashing Robots Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7799   Accepted: 3388 D ...

  8. POJ2632 Crashing Robots 解题报告

    Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is neede ...

  9. 【POJ2632】Crashing Robots

    题目传送门 本题知识点:模拟 模拟机器人的运作过程,分别有三种功能,L 则是左转90°,R 则是右转90°,L 则是前进1格.让我们去模拟并判断它们的状态. 输入: 第一行是测试样例 第二行分别是矩形 ...

随机推荐

  1. iOS中CocoaPads的安装与配置(总结)

    来说一下安装CocoaPots的顺序: Xcode->homebrew->RVM->Ruby->CocoaPats; 这篇文章之讲解如何安装到Ruby的部分,关于安装好Ruby ...

  2. rabbitMQ+yii2 使用

    安装rabbitMQ 见此文章 http://www.cnblogs.com/zxxyx/p/6229613.html 安装好之后 出现此目录: 然后需要yii里面进行载入: 这个目录下面: 加上这个 ...

  3. VUE 入门基础(8)

    十,组件 使用组件 注册 可以通过以下这种方式创建一个Vue实例 new Vue({ el: '#some-element', }) 注册一个全局组件,你可以使用Vue.component(tagNa ...

  4. iOS图片编辑功能实现

    图片加标签:标签可以编辑 https://github.com/shumingli/waterMark 1. 编辑效果;图片可以放到.缩小.旋转 2. 保存相册效果

  5. Request Entity Too Large for Self Hosted ASP.Net Web API在Selfhost的api后台怎么解决Request Entity Too Large问题

    Request Entity Too Large for Self Hosted ASP.Net Web API在Selfhost的api后台怎么解决Request Entity Too Large问 ...

  6. SQL Server中Rowcount与@@Rowcount的用法

    rowcount的用法: rowcount的作用就是用来限定后面的sql在返回指定的行数之后便停止处理,比如下面的示例, set rowcount 10select * from 表A 这样的查询只会 ...

  7. 关于odbc的彻底删除问题

    最近在装一个软件,由于第一次安装产生了一个错误,于是我尝试在卸载之后,重新进行安装~但是,在安装过程当中出现了一个问题. NEWLRE ODBC data source already exists. ...

  8. javascript-binarySearch

    前提: 数组已排序,且为正整数数组. function brnarySearch(arg, arr) { var right = arr.length - 1; var left = 0; while ...

  9. Word2013创建目录

    1.写好文档内容后,将光标移到标题行,点击“开始”里的“样式”->“创建样式”,为该标题创建一个新的样式,同时点击“修改”,在打开的窗口中选择左下方的“格式”,进行标题格式的调整.依次可设定子标 ...

  10. SpringMVC 表单复选框处理

    <form action="" method="post"> <c:forEach items="${dblist}" v ...