#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. 思达index网站

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. 关于asp.net 开发的小技巧—让传值对象化

    前端:前端 定义一个对象, 传值时实例此对象,序列化成json字符串 代码如下: 定义js对象: ///定义一个查询条件对象 var SearchCondition=function(){ this. ...

  3. Mac下Call to undefined function imagettftext() 解决方案

    文章转载至Mac下Call to undefined function imagettftext()终极解决方案 安装了一套onethink程序准备调试,结果在登录页面发现验证码无法显示,单独访问验证 ...

  4. HP_UX HBA 卡信息收集脚本

    #/usr/bin/shname1=`hostname`_fcioscan -kfnNC fc |grep "/dev/" >/tmp/data/$name1.txtnum1 ...

  5. mysql的多实例安装

    单机多实例据说可以最大程度提高硬件使用,谁知道呢,但是以前的公司喜欢这样搞,我最近也在学习复制什么的,电脑搞不起两台虚拟机,刚好单机多实例可以解救我.下面就说说步骤. 承上文http://www.cn ...

  6. 使用WebClient 或者 HttpWebRequest均报:"The Remote name can't be solved"

    错误原因: 未配置代理服务器设置的问题, 需要在配置节做如下操作. ============================================ 文章编号: 318140 - 查看本文应用 ...

  7. Python-day-21

    1.请求周期 url> 路由 > 函数或类 > 返回字符串或者模板语言? Form表单提交: 提交 -> url > 函数或类中的方法 - .... HttpRespon ...

  8. C89和C99区别--简单总结

    (1)对数组的增强 可变长数组 C99中,程序员声明数组时,数组的维数可以由任一有效的整型表达式确定,包括只在运行时才能确定其值的表达式,这类数组就叫做可变长数组,但是只有局部数组才可以是变长的.可变 ...

  9. 【python】迭代器&生成器

    源Link:http://www.cnblogs.com/huxi/archive/2011/07/01/2095931.html 迭代器 迭代器是访问集合元素的一种方式.迭代器对象从集合的第一个元素 ...

  10. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->关于spring framework中的beans

    Spring framework中的beans 1.概述 bean其实就是各个类实例化后的对象,即objects spring framework的IOC容器所管理的基本单元就是bean spring ...