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格.让我们去模拟并判断它们的状态. 输入: 第一行是测试样例 第二行分别是矩形 ...
随机推荐
- 给VMware下的Linux扩展磁盘空间(以CentOS6.5为例)
#查看挂载点:df -h#显示: 文件系统 容量 已用 可用 已用%% 挂载点/dev/mapper/vg_dc01-lv_root47G 12G 34G 25% /tmpfs 504M 88K 50 ...
- ubuntu14.04下安装cudnn5.1.3,opencv3.0,编译caffe及配置matlab和python接口过程记录
已有条件: ubuntu14.04+cuda7.5+anaconda2(即python2.7)+matlabR2014a 上述已经装好了,开始搭建caffe环境. 1. 装cudnn5.1.3,参照: ...
- HDOJ(2438)几何里的三分
Turn the corner http://acm.hdu.edu.cn/showproblem.php?pid=2438 题目:一辆车能否在一个路口拐弯,看图就很明白啦. 算法:见下图,只要求出图 ...
- prolog 阶段总结
http://blog.csdn.net/mwsong/article/details/1766382 到现在为止,我们已经对Prolog有了一个基本的了解,现在有必要对我们所学过的知识做一个系统 ...
- VB调用存储过程 - CreateParameter 方法
这次又转为VB6了....... (┬_┬) ---------------------------------------------------------------------------- ...
- SDRAM的主要参数
(1) 容量.SDRAM的容量经常用XX存储单元×X体×每个存储单元的位数来表示.例如某SDRAM芯片的容量为4M×4×8bit,表明该存储器芯片的容量为16 M字节.或128 M bit. (2) ...
- 设置Headers
import urllib import urllib2 url = 'http://www.server.com/login'user_agent = 'Mozilla/4.0 (compatibl ...
- DIOCP之工作流程图
晚上更新,请大家多多理解,最近比较忙
- 顶点着色器详解 (Vertex Shaders)
学习了顶点处理,你就知道固定功能流水线怎么将顶点从模型空间坐标系统转化到屏幕空间坐标系统.虽然固定功能流水线也可以通过设置渲染状态和参数来改变最终输出的结果,但是它的整体功能还是受限.当我们想实现一个 ...
- SQL Server 导入数据失败:无法在只读列“Id”中插入数据
解决方案: 在数据库导入"选择源表和源视图"->点击对应表后的“编辑映射”按钮->勾选“启用标识列插入”->导入即可.