题目链接

分析:

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

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

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. Struts2自己定义拦截器实例—登陆权限验证

    版本号:struts2.1.6 此实例实现功能:用户须要指定username登陆,登陆成功进入对应页面运行操作,否则返回到登陆页面进行登陆,当直接訪问操作页面(登陆后才干訪问的页面)时则不同意,须返回 ...

  2. Bloom Filter 原理与应用

    介绍 Bloom Filter是一种简单的节省空间的随机化的数据结构,支持用户查询的集合.一般我们使用STL的std::set, stdext::hash_set,std::set是用红黑树实现的,s ...

  3. [AngularJS] Enable Animations Explicitly For A Performance Boost In AngularJS

    http://www.bennadel.com/blog/2935-enable-animations-explicitly-for-a-performance-boost-in-angularjs. ...

  4. 定制属于自己的Chrome起始页

    个人感觉没什么技术含量,可是很有用.我定制的起始页面例如以下: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd2FuZ19saWNodW4=/font/5 ...

  5. Java基础知识强化之集合框架笔记09:Collection集合迭代器使用的问题探讨

    1.Collection集合迭代器使用的问题探讨: (1)问题1:能用while循环写这个程序,我能不能用for循环呢?                  可以使用for循环替代. (2)问题2:不要 ...

  6. zoj 3537 Cake(区间dp)

    这道题目是经典的凸包的最优三角剖分,不过这个题目给的可能不是凸包,所以要提前判定一下是否为凸包,如果是凸包的话才能继续剖分,dp[i][j]表示已经排好序的凸包上的点i->j上被分割成一个个小三 ...

  7. Break和Continue的一些注意事项

    Break: 1)可以用于switch-case判断中,用于跳出switch 2)用在循环中,用于立即跳出循环 其中,用于循环的情况下,跳出的是break所在的循环 Continue: 立即结束本次循 ...

  8. UWP app HelloWorld 的创建

    步骤 1:在 Visual Studio 中创建新项目 启动 Visual Studio 2015 RC.将出现 Visual Studio 2015 RC 起始页. (从现在开始,我们将 Visua ...

  9. MySQL存储过程的基本函数(三)

    (1).字符串类 首先定义一个字符串变量:set @str="lxl"; CHARSET(str) //返回字串字符集 select charset(@str);+-------- ...

  10. 关于<:if>没有<c:else>解决方案

    <c:if>没有<c:else>可以用<c:choose>来取代结构: <c:choose> <c:when test=""& ...