poj2632 累死了
题意:
给定A*B的格子,放入N个机器人,每个机器人初始位置及朝向给定。给定M条指令。指令类型有三种:
1、L:左转90° 2、R:右转90° 3、F:前进一格
问执行指令过程中机器人是否发生碰撞,碰撞包括碰墙或碰其他机器人。安全执行完所有指令输出OK。(程序只需输出发生的第一次碰撞)
第一发我定义了一个cnate[20000][20000]直接空间爆炸
第二发不知道走过的路径中碰到机器人的话也算碰撞
第三发到第五发坐标建立错误(看图就知道了) 最后实在不知道了就看了下别人的题解...

最后总结一下:这种模拟题一定要根据题目意思来,题目是什么就怎么模拟,唉,可怜我这种英语渣渣。
这道题前前后后做了四个小时...
#include<cstdio>
#include<cstring>
#include<cmath>
const int maxn = + ;
int cnate[maxn][maxn];
int dx[] = {,,,-};
int dy[] = {,,-,};
int zhuang=,beizhuang=;
char s[];
using namespace std;
struct Robots{
int x,y,d;
}r[maxn];
int main()
{
int n,m,e=,flag;
int t;int a,b;
scanf("%d",&t);getchar();
while(t--){
flag=;
memset(cnate,,sizeof(cnate));
scanf("%d %d",&a,&b);scanf("%d %d",&n,&m);
for(int i=;i<=n;i++){
scanf("%d %d",&r[i].x,&r[i].y);
scanf("%s",s);cnate[r[i].y][r[i].x]=i; //就是这里,建立坐标
switch(s[]){
case 'N':r[i].d=;break;
case 'E':r[i].d=;break;
case 'S':r[i].d=;break;
case 'W':r[i].d=;break;
}
}
char act[];int num,rep;
while(m--){
scanf("%d %s %d",&num,act,&rep);
if(!flag){
if(act[]=='L') r[num].d=((r[num].d-rep)%+)%;
else if(act[]=='R') r[num].d=(r[num].d+rep)%;
else{
cnate[r[num].y][r[num].x] = ;
for(int i=;i<rep;++i){
r[num].x+=dx[r[num].d];
r[num].y+=dy[r[num].d];
if(r[num].x<=||r[num].x>a||r[num].y<=||r[num].y>b){
zhuang=num;flag=;break;
}
else if(cnate[r[num].y][r[num].x]){
zhuang=num;beizhuang=cnate[r[num].y][r[num].x];
flag=;break;
}
}
if(!flag) cnate[r[num].y][r[num].x] = num;
}
}
}
if(flag==) printf("Robot %d crashes into the wall\n", zhuang);
else if(flag==) printf("Robot %d crashes into robot %d\n", zhuang, beizhuang);
else printf("OK\n");
}
return ;
}
poj2632 累死了的更多相关文章
- POJ-2632 Crashing Robots模拟
题目链接: https://vjudge.net/problem/POJ-2632 题目大意: 在一个a×b的仓库里有n个机器人,编号为1到n.现在给出每一个机器人的坐标和它所面朝的方向,以及m条指令 ...
- 为了用python计算一个汉字的中心点,差点没绞尽脑汁活活累死
为了用python计算一个汉字的中心点,差点没绞尽脑汁活活累死
- POJ2632
#include<stdio.h> #include<string.h> #include<algorithm> #include<cmath> usi ...
- hadoop多次搭建后,完整总结(累死宝宝了,搭建了十多遍了)
1.安装JDK1.1上传运用软件FileZilla,将windows上的jdk压缩包放到linux的root目录下 1.2解压jdk #创建文件夹 mkdir /usr/java(不要挂在在" ...
- 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 ...
随机推荐
- 2013B题碎纸片拼接
Photo1_1: clear;clc; path='E:\B\附件1\'; files=dir('E:\B\附件1\*.bmp'); % objdir='E:\B\附件1\'; % bgfile=[ ...
- 使用FastJson对实体类和Json还有JSONObject之间的转换
1. 实体类或集合转JSON串 String jsonString = JSONObject.toJSONString(实体类); 2.JSON串转JSONObject JSONObject json ...
- vue组件通信全面总结
写在前面 组件间的通信是是实际开发中非常常用的一环,如何使用对项目整体设计.开发.规范都有很实际的的作用,我在项目开发中对此深有体会,总结下vue组件间通信的几种方式,讨论下各自的使用场景 文章对相关 ...
- layers.py cs231n
如果有错误,欢迎指出,不胜感激. import numpy as np def affine_forward(x, w, b): 第一个最简单的 affine_forward简单的前向传递,返回 ou ...
- malloc: *** error for object 0x10a291df8: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug
malloc_error_break错误: .You'll find out what the object is when you break in the debugger. Just look ...
- mysql存储过程小解
mysql 存储过程 1.创建语法 delimiter $$ --$$表示改变默认的分隔符,代表以下为存储过程,不然会以SQL的方式执行 drop procedure if exists pro_na ...
- spring-data-jpa实体类继承抽象类如何映射父类的属性到数据库
在抽象父类上加上注解@MappedSuperclass @MappedSuperclass public class Pet { private Integer id;//id private Str ...
- 2019-10-18-dotnet-文件读写务必注意事项
title author date CreateTime categories dotnet 文件读写务必注意事项 lindexi 2019-10-18 08:42:53 +0800 2019-10- ...
- 对The Curse of Dimensionality(维度灾难)的理解
一个特性:低维(特征少)转向高维的过程中,样本会变的稀疏(可以有两种理解方式:1.样本数目不变,样本彼此之间距离增大.2.样本密度不变,所需的样本数目指数倍增长). 高维度带来的影响: 1.变得可分. ...
- HTML5入门指南
1.HTML5到底是什么? HTML5是HTML最新的修订版本,2014年10月由万维网联盟(W3C)完成标准制定.目标是取代1999年所制定的HTML 4.01和XHTML 1.0标准,以期能在互联 ...