POJ2632
#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的更多相关文章
- POJ-2632 Crashing Robots模拟
题目链接: https://vjudge.net/problem/POJ-2632 题目大意: 在一个a×b的仓库里有n个机器人,编号为1到n.现在给出每一个机器人的坐标和它所面朝的方向,以及m条指令 ...
- poj2632 Crashing Robots
Crashing Robots Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9859 Accepted: 4209 D ...
- poj2632 模拟
Crashing Robots Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8388 Accepted: 3631 D ...
- POJ2632——Crashing Robots
Crashing Robots DescriptionIn a modernized warehouse, robots are used to fetch the goods. Careful pl ...
- POJ2632 Crashing Robots(模拟)
题目链接. 分析: 虽说是简单的模拟,却调试了很长时间. 调试这么长时间总结来的经验: 1.坐标系要和题目建的一样,要不就会有各种麻烦. 2.在向前移动过程中碰到其他的机器人也不行,这个题目说啦:a ...
- poj2632 【模拟】
In a modernized warehouse, robots are used to fetch the goods. Careful planning is needed to ensure ...
- 快速切题 poj2632
Crashing Robots Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7799 Accepted: 3388 D ...
- POJ2632 Crashing Robots 解题报告
Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is neede ...
- 【POJ2632】Crashing Robots
题目传送门 本题知识点:模拟 模拟机器人的运作过程,分别有三种功能,L 则是左转90°,R 则是右转90°,L 则是前进1格.让我们去模拟并判断它们的状态. 输入: 第一行是测试样例 第二行分别是矩形 ...
随机推荐
- etc 安装及使用
键值存储仓库,用于配置共享和服务发现. A highly-available key value store for shared configuration and service discover ...
- mysql source导入报错ERROR 1366的解决方法
文件是utf8的,数据库表是utf8的,为什么客户端导入会报错呢? 发现客户端用的是gbk的 改为utf8后正常 SHOW VARIABLES LIKE 'character%'; +-------- ...
- MySQL的索引类型和左前缀索引
1.索引类型: 1.1B-tree索引: 注:名叫btree索引,大的方面看,都用的是平衡树,但具体的实现上,各引擎稍有不同,比如,严格的说,NDB引擎,使用的是T-tree,但是在MyISAM,In ...
- RichEdit 追加 RTF
下面实现追加RTF 到 RichEdit 的功能其本质是:EM_STREAMIN 消息,详细查看 MSDN//--------------------------------------------- ...
- --- shell 扩展的顺序
1. 扩展(expansion)是bash 解释器的重要的概念: 2. 命令替换是扩展里面的一种 3. 基本结构是: “字符串准备(花括号,波浪线,参数和变量扩展,命令替换),单词分割,路径扩展” h ...
- Java入门记(四):容器关系的梳理(上)——Collection
目录 一.Collection及子类/接口容器继承关系 二.List 2.1 ArrayList 2.1.1 序列化的探讨 2.1.2 删除元素 2.1.3 调整大小 2.2 Vector和Stack ...
- 线程小demo
下午就手写了两个demo,整理了一下. #!/sur/bin/env python # -*- coding:utf-8 -*- __author__ = 'ganzl' import threadi ...
- python爬虫——黑板客老师课程学习
程序: 目标url 内容提取 表现形式 为什么: 大数据——数据膨胀,信息太多了,不知道哪些信息适合你,例如谷歌搜索引擎. 垂直行业搜索——某一个行业的搜索,与搜索引擎最大的区别:搜索引擎是告诉你哪些 ...
- cf727e
题意:给你一个模式串和一堆长度相同的不相同的匹配串,问是否有一个方案可以让这个模式串由这些匹配串首尾相连组成,每个串只能出现一次. 思路:还是比较简单的,显然模式串每个位置最多匹配一个匹配串,因为所有 ...
- JS正则表达式验证账号、手机号、电话和邮箱
JS正则表达式验证账号.手机号.电话和邮箱 效果体验:http://keleyi.com/keleyi/phtml/jstexiao/15.htm 验证帐号是否合法 验证规则:字母.数字.下划线组成, ...