题目链接

分析:

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

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

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. hdu 1882 Strange Billboard(位运算+枚举)

    http://acm.hdu.edu.cn/showproblem.php?pid=1882 感觉非常不错的一道题. 给一个n*m(1<=n,m<=16)的矩阵,每一个格子都有黑白两面,当 ...

  2. Java基础知识强化之IO流笔记17:FileOutputStream构造方法使用

    1. 可以参照之前写的笔记:   Android(java)学习笔记167:Java中操作文件的类介绍(File + IO流) 2. FileOutputStream(常用的)构造方法: FileOu ...

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

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

  4. 【开源java游戏框架libgdx专题】-02-Eclipse Gradle 环境安装

    创建eclipse开发环境 Eclipse 4.5 Help -> install newsoftware 填上下载地址(Eclipse 4.5及以上版本): http://dist.sprin ...

  5. javascript 实用函数

    1.去除字符串空格 /*去左空格*/ function ltrim(s) { return s.replace(/^(\s*| *)/, ""); } /*去右空格*/ funct ...

  6. jquery属性选择器之 attr

    在温习jquery手册的时候,注意到这个,坐下记录. attr(name|properties|key,value|fn) 获取匹配的元素集合中的第一个元素的属性的值 或 设置每一个匹配的元素的一个或 ...

  7. 注册表修改IP地址和DNS等信息

    ---------------------win8系统 1. 2. 3. --------------------------------------------------------------- ...

  8. Google2016开发者大会

    Android主讲: 一.吴晶:android笔记博主(博客:http://www.race604.com/) 主题:Android低功耗蓝牙(BLE)实践 低功耗蓝牙在可穿戴和智能家居里边用的比较多 ...

  9. win7+SQL2008无法打开物理文件 操作系统错误 5:拒绝访问 SQL Sever

    今天在win7+SQL2008的环境下操作分离附加数据库,分离出去然后再附加,没有问题.但是一把.mdf文件拷到其它文件夹下就出错,错误如下:无法打开物理文件 "E:\db\MyDB.mdf ...

  10. 10个加速Table Views开发的Tips(转)

    本文由CocoaChina译者yake_099(博客)翻译,作者:David McGraw原文:10 Actionable Performance Tips To Speed Up Your Tabl ...