模拟,题意看了一小时

/* ***********************************************
Author :Zhou Zhentao
Email :774388357@qq.com
Created Time :2015/12/15 13:19:28
File Name :main.cpp
************************************************ */ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std; const int maxn=+;
int Map[maxn][maxn];
char s[+];
int ans[+];
int R,C,x,y; bool P(int x,int y)
{
if(x>=&&x<=R)
{
if(y>=&&y<=C)
{
return ;
}
}
return ;
} int main()
{
while(~scanf("%d%d",&R,&C))
{
memset(Map,,sizeof Map);
scanf("%d%d",&x,&y);
Map[x][y]=;
ans[]=;
scanf("%s",s);
int len=strlen(s);
for(int i=; i<len; i++)
{
if(i==len-)
{
int num=;
for(int i=; i<=R; i++)
{
for(int j=; j<=C; j++)
{
if(Map[i][j]==) num++;
}
}
ans[i+]=num;
break;
}
else
{
int NewX,NewY;
if(s[i]=='U')
{
NewX=x-;
NewY=y;
}
else if(s[i]=='D')
{
NewX=x+;
NewY=y;
}
else if(s[i]=='L')
{
NewX=x;
NewY=y-;
}
else if(s[i]=='R')
{
NewX=x;
NewY=y+;
}
if(P(NewX,NewY))
{
x=NewX;
y=NewY;
if(Map[NewX][NewY]==)
{
Map[x][y]=;
ans[i+]=;
}
else ans[i+]=;
}
else ans[i+]=;
}
}
for(int i=; i<=len; i++)
{
printf("%d",ans[i]);
if(i<len) printf(" ");
else printf("\n");
}
}
return ;
}

CodeForces 606B Testing Robots的更多相关文章

  1. Codeforces Round #335 (Div. 2) 606B Testing Robots(模拟)

    B. Testing Robots time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  2. codeforce 606B Testing Robots

    题意:给定一个x*y的矩形,和一个机器人的初始位置(x0,y0).以向下为x轴正方向,向右为y轴正方向.现在要对这个机器人进行多次测试.每次测 试,会在矩形的某个位置有一个矿井.所以一共要进行x*y次 ...

  3. Codeforces Round #335 (Div. 2) B. Testing Robots 水题

    B. Testing Robots Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606 ...

  4. Codeforces Round #335 (Div. 2)B. Testing Robots解题报告

                                                                                               B. Testin ...

  5. Codeforces 1045G AI robots [CDQ分治]

    洛谷 Codeforces 简单的CDQ分治题. 由于对话要求互相看见,无法简单地用树套树切掉,考虑CDQ分治. 按视野从大到小排序,这样只要右边能看见左边就可以保证互相看见. 发现\(K\)固定,那 ...

  6. Codeforces Round #335 (Div. 2)

    水 A - Magic Spheres 这题也卡了很久很久,关键是“至少”,所以只要判断多出来的是否比需要的多就行了. #include <bits/stdc++.h> using nam ...

  7. Codeforces Round #335 (Div. 2) B

    B. Testing Robots time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  8. Android单元测试与模拟测试详解

    测试与基本规范 为什么需要测试? 为了稳定性,能够明确的了解是否正确的完成开发. 更加易于维护,能够在修改代码后保证功能不被破坏. 集成一些工具,规范开发规范,使得代码更加稳定( 如通过 phabri ...

  9. Codeforces Round #350 (Div. 2) B. Game of Robots 水题

    B. Game of Robots 题目连接: http://www.codeforces.com/contest/670/problem/B Description In late autumn e ...

随机推荐

  1. button的action属性如果有参数,必须加“:”

    比如: [bt addTarget:self action:@selector(shareButtonClickHandler:) …… 后面未写完 一开始我没加,就报错.

  2. 1.java.io包中定义了多个流类型来实现输入和输出功能,

    1.java.io包中定义了多个流类型来实现输入和输出功能,可以从不同的角度对其进行分 类,按功能分为:(C),如果为读取的内容进行处理后再输出,需要使用下列哪种流?(G)   A.输入流和输出流 B ...

  3. asp.net 基础

    前台HTML,javascript,后台C# 代码能不在后台写,就不在后台写 WebSite和WebApplication的区别 1)当改变后台代码时,WebApplication需重启浏览器或者重新 ...

  4. 使用TcpTrace小工具截获Web Service的SOAP报文

    Web Service客户端对服务端进行调用时,请求和响应都使用SOAP报文进行通讯.在开发和测试时,常常查看SOAP报文的内容,以便进行分析和调试.TcpTrace是一款比较小巧的工具,可以让我们截 ...

  5. rebar

    www.cnblogs.com/panfeng412/archive/2011/08/14/2137990.html

  6. git 提交到github时不用每次都输入用户名,密码

    Permanently authenticating with Git repositories, Run following command to enable credential caching ...

  7. 2.1 sikuli 中编程运行

    1.用sikuli编程时,多用wait()语句,因为很多时候没有给它一定的识别时间,就容易出错. 比如下图,保证页面加载时间 1.Sikuli中 ,可以加# 进行注释 但是注释有的时候也会不起作用,比 ...

  8. ios view改变背景图

    一般我们设置 一个view的背景  可以通过  在view上放一个imageView 来显示背景图片 这里介绍另外一种方法 可以直接通过改变view.backgroundColor的值 来达到上面的效 ...

  9. 事务(JDBC、Hibernate、Spring)

    如果不用spring管理事务,我们自己写代码来操作事务.那么这个代码怎么写要看底层怎么访问数据库了. 当采用原生JDBC访问数据库时,操作事务需要使用java.sql.Connection的API.开 ...

  10. tiny210 u-boot 网络ping不通主机解决方案

    站在巨人的肩膀上: http://blog.csdn.net/liukun321/article/details/7438880 http://www.arm9home.net/read.php?ti ...