题目链接

分析:

虽说是简单的模拟,却调试了很长时间。

调试这么长时间总结来的经验:

1.坐标系要和题目建的一样,要不就会有各种麻烦。

2.在向前移动过程中碰到其他的机器人也不行,这个题目说啦:a robot always completes its move before the next one starts moving。

#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; const int maxn = + ; int G[maxn][maxn]; int dx[] = {, , , -};
int dy[] = {, , -, }; struct Robots{
int x, y, d;
}r[+]; int main(){
int A, B, n, m, T, flag, rob, cra_rob;
char s[]; scanf("%d", &T); while(T--) {
flag = ; memset(G, , sizeof(G)); 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);
G[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;
}
} int num, rep;
char act[]; 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 {
G[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].y <= || r[num].x > A || r[num].y > B) {
rob = num;
flag = ;
break;
} else if(G[r[num].y][r[num].x]) {
rob = num;
cra_rob = G[r[num].y][r[num].x];
flag = ;
break;
}
} if(!flag) G[r[num].y][r[num].x] = num;
}
}
} if(flag == ) printf("Robot %d crashes into the wall\n", rob);
else if(flag == ) printf("Robot %d crashes into robot %d\n", rob, cra_rob);
else printf("OK\n");
} return ;
}

POJ2632 Crashing Robots(模拟)的更多相关文章

  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

    Crashing Robots DescriptionIn a modernized warehouse, robots are used to fetch the goods. Careful pl ...

  4. POJ2632 Crashing Robots 解题报告

    Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is neede ...

  5. poj 2632 Crashing Robots 模拟

    题目链接: http://poj.org/problem?id=2632 题目描述: 有一个B*A的厂库,分布了n个机器人,机器人编号1~n.我们知道刚开始时全部机器人的位置和朝向,我们可以按顺序操控 ...

  6. POJ 2632 Crashing Robots (模拟 坐标调整)(fflush导致RE)

    题目链接:http://poj.org/problem?id=2632 先话说昨天顺利1Y之后,直到今天下午才再出题 TAT,真是刷题计划深似海,从此AC是路人- - 本来2632是道略微恶心点的模拟 ...

  7. POJ 2632 Crashing Robots 模拟 难度:0

    http://poj.org/problem?id=2632 #include<cstdio> #include <cstring> #include <algorith ...

  8. 模拟 POJ 2632 Crashing Robots

    题目地址:http://poj.org/problem?id=2632 /* 题意:几个机器人按照指示,逐个朝某个(指定)方向的直走,如果走过的路上有机器人则输出谁撞到:如果走出界了,输出谁出界 如果 ...

  9. Crashing Robots(水题,模拟)

    1020: Crashing Robots 时间限制(普通/Java):1000MS/10000MS     内存限制:65536KByte 总提交: 207            测试通过:101 ...

随机推荐

  1. 3D游戏引擎一 win32编程

    Windows程序一般都等待用户进行一些操作,然后响应并採取行动. 一般来说.对win32的程序的操作都会转换为系统事件队列中的消息,如按键消息WM_KEYDOWN,WM_MOUSECLICK等传递键 ...

  2. uva:10340 - All in All(字符串匹配)

    题目:10340 - All in All 题目大意:给出字符串s和t,问s是否是t的子串.s若去掉某些字符能和t一样,那么t是s的子串. 解题思路:匹配字符.t的每一个字符和s中的字符匹配.注意这里 ...

  3. SmartFoxServer 2x的pythonclient

    最近的研究SmartFoxServer 2x.这是一个对网络游戏的Web开发框架.服务器基于java netty为发展框架,client支持flash,unity, ios, android(java ...

  4. CSDN Markdown简明教程5-高速上手

    0.文件夹 文件夹 前言 CSDN Markdown特点 CSDN Markdown高速上手 1 使用快捷键 粗体斜体 引用 链接 高亮代码块 图片 标题 列表 切割线 撤销反复 2 使用离线写作 3 ...

  5. cocos2d-x项目过程记录(纹理和内存优化方面)

    1.参考资料:Cocos2d-x纹理优化的一些方案  cocos2d-x如何优化内存的应用  iOS和android游戏纹理优化和内存优化(cocos2d-x) 2.加载贴图集纹理 CCSpriteF ...

  6. C#中的操作数据库的SQLHelper类

    using System; using System.Collections.Generic; using System.Configuration; using System.Data; using ...

  7. ASP.NET-FineUI开发实践-15

    1.按条件控制Grid不可编辑     Grid编辑其实用到的不多...但是也有要控制权限或者其他条件不能编辑的情况其实挺简单,学过extjs的知道,我现在也只是写前台了,没有写到后台事件,有时间再说 ...

  8. 【转】ibatis的简介与初步搭建应用

    [转]ibatis的简介与初步搭建应用 一.ibatis的简介 ibatis是什么东西就不介绍了,自己去找谷老师. 这里讲下自己的使用体会.之前自己学过Hibernate,是看尚学堂的视频教学的,看完 ...

  9. segue生命周期

    segue生命周期:概述: 理解segue工作原理,需要理解一个segue对象的生命周期.segue对象是UIStoryboardSegue的实例或者是它的一个子类.所有iOS app都不能直接创建s ...

  10. 对于HttpContext.Current的一点理解

    string[] userInfomationSplits = HttpContext.Current.User.Identity.Name.Split(new string[] { "\\ ...