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 ...
随机推荐
- WPF MVVM简单介绍
前面文章中,我们已经知道,WPF技术的主要特点是数据驱动UI,所以在使用WPF技术开发的过程中是以数据为核心的,WPF提供了数据绑定机制,当数据发生变化时,WPF会自动发出通知去更新UI. 我们不管 ...
- 关于Python缩进,我们该了解哪些?
Python是一门独特的语言,它的代码块是通过缩进(Indentation)来标记的(大部分语言都是使用花括号作为代码块的标记),具有相同缩进的多行代码属于同一个代码块.如果代码莫名其妙的乱缩进,Py ...
- 【水滴石穿】github_popular
项目不难,就是文件摆放位置跟别的不一样 https://github.com/chenji336/github_popular //定义入口是app.js ///** @format */ impor ...
- JavaScript--放大镜
上例图: <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF- ...
- IntelliJ IDEA 添加项目后编译显示包不存在的解决方案
File -> Project Structure -> Modules 看看是否有多个项目,删掉无用的.或者调整一下项目,重新 Mark as 一下,指定成 Sources
- Java练习 SDUT-2192_救基友记2
救基友记2 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 屌丝WP的好基友CZ又被妖鬼给抓走了(CZ啊,CZ-.怎么说 ...
- PHPCMS快速建站系列之标签循环嵌套
标签循环嵌套方法,可以实现对PC标签循环调用,代码如下: 在此文件里/phpcms/lib/classes/template_cache.class.php 里的 template_parse 方法里 ...
- 洛谷P3455 [POI2007]ZAP-Queries (莫比乌斯反演)
题意:求$\sum_{i=1}^{a}\sum_{j=1}^{b}[gcd(i,j)==d]$(1<=a,b,d<=50000). 很套路的莫比乌斯反演. $\sum_{i=1}^{n}\ ...
- Person Re-identification 系列论文笔记(四):Re-ID done right: towards good practices for person re-identification
Re-ID done right: towards good practices for person re-identification Almazan J, Gajic B, Murray N, ...
- VS开发ArcEngine时的一个异常信息——“ArcGIS version not specified. You must call RuntimeManager.Bind before creating any ArcGIS components.”
问题描述:程序报错“ArcGIS version not specified. You must call RuntimeManager.Bind before creating any ArcGIS ...