题目链接

分析:

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

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

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. Project Euler problem 63

    这题略水啊 首先观察一下. 10 ^ x次方肯定是x + 1位的 所以底数肯定小于10的 那么我们就枚举1~9为底数 然后枚举幂级数就行了,直至不满足题目中的条件即可break cnt = 0 for ...

  2. <<java 并发编程>>第七章:取消和关闭

    Java没有提供任何机制来安全地终止线程,虽然Thread.stop和suspend等方法提供了这样的机制,但是存在严重的缺陷,应该避免使用这些方法.但是Java提供了中断Interruption机制 ...

  3. Eclipse快捷键 10个最有用的快捷键(转)

    Eclipse中10个最有用的快捷键组合  一个Eclipse骨灰级开发者总结了他认为最有用但又不太为人所知的快捷键组合.通过这些组合可以更加容易的浏览源代码,使得整体的开发效率和质量得到提升.    ...

  4. Windows与Linux文件共享

    Windows与Linux文件共享 Samba服务器 安装Samba服务器 rpm –ivh /mnt/Packages/Samba-3.5.10-125.el6.i686.rpm 添加用户并修改密码 ...

  5. 关于c#流

     C#流的简单认识 前言 本篇文章简单总结了在C#编程中经常会用到的一些流.比如说FileStream.MemoryStream. BufferedStream. NetWorkStream. Str ...

  6. java中的数据库事务处理

    /*java使用事务处理,首先要求数据库支持事务,如使用MYSQL的事务功能,就要求mysql的表类型为Innodb,*/ /*InnoDB,是MySQL的数据库引擎之一 与传统的ISAM与MyISA ...

  7. (转)PHP数组的总结(很全面啊)

    一.什么是数组数组就是一组数据的集合,把一系列数据组织起来,形成一个可操作的整体.数组的每个实体都包含两项:键和值. 二.声明数据在PHP中声明数组的方式主要有两种:一是应用array()函数声明数组 ...

  8. c-指针的指针

    概述: 贴上一个'经典C语言程序设计100例'的第77个程序 #include <stdio.h> int main(void) { char *s[]={"man", ...

  9. javadoc in archive eclipse.

    Open Windows -> Preferences. 2.Select jre from Installed JREs then hit Edit botton on the right. ...

  10. Python的参数模块OptionParser说明

    可以替代getopt的一个模块 from optparse import OptionParser #  生成一个实例 parser = OptionParser(usage="%prog ...