CodeForces 606B Testing Robots
模拟,题意看了一小时
/* ***********************************************
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的更多相关文章
- 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 ...
- codeforce 606B Testing Robots
题意:给定一个x*y的矩形,和一个机器人的初始位置(x0,y0).以向下为x轴正方向,向右为y轴正方向.现在要对这个机器人进行多次测试.每次测 试,会在矩形的某个位置有一个矿井.所以一共要进行x*y次 ...
- 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 ...
- Codeforces Round #335 (Div. 2)B. Testing Robots解题报告
B. Testin ...
- Codeforces 1045G AI robots [CDQ分治]
洛谷 Codeforces 简单的CDQ分治题. 由于对话要求互相看见,无法简单地用树套树切掉,考虑CDQ分治. 按视野从大到小排序,这样只要右边能看见左边就可以保证互相看见. 发现\(K\)固定,那 ...
- Codeforces Round #335 (Div. 2)
水 A - Magic Spheres 这题也卡了很久很久,关键是“至少”,所以只要判断多出来的是否比需要的多就行了. #include <bits/stdc++.h> using nam ...
- Codeforces Round #335 (Div. 2) B
B. Testing Robots time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Android单元测试与模拟测试详解
测试与基本规范 为什么需要测试? 为了稳定性,能够明确的了解是否正确的完成开发. 更加易于维护,能够在修改代码后保证功能不被破坏. 集成一些工具,规范开发规范,使得代码更加稳定( 如通过 phabri ...
- 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 ...
随机推荐
- jetty访问jsp页面出现( PWC6345: There is an error in invoking javac)
org.apache.jasper.JasperException: PWC6345: There is an error in invoking javac. A full JDK (not ju ...
- think in uml 1
对象,在过程的基础上,是一个抽象级别的提升,可以构建更大更复杂的系统 数据流图(Data Flow Diagram):简称DFD,它从数据传递和加工角度,以图形方式来表达系统的逻辑功能.数据在系统内部 ...
- Linux 配置tomcat遇见的若干问题
1.提示catalina.sh缺失 原因:未对bin目录下的.sh文件授权 执行:chmod +x bin/*.sh即可 2.正常启动Tomcat 但是外界无法访问 Linux防火墙原因,进入到 et ...
- ANT 操控 ORACLE数据库实践
Ant 执行系统命令没有任何问题,这次实际系统命令中可以说遇到了两个问题,一个是启动服务的命令是含有空格的,第二个如何备份数据库可以自动加上日期. 首先,我们启动oracle数据库,操作有两个: 1. ...
- Form表单的post 和get跳转区别
post是隐示请求 ----- 安全 get显示请求不安全,会在URL上显示路径和参数
- Android OpenGL ES(十)绘制三角形Triangle .
三角形为OpenGL ES支持的面,同样创建一个DrawTriangle Activity,定义6个顶点使用三种不同模式来绘制三角形: float vertexArray[] = { -0.8f, - ...
- Python定制类
https://docs.python.org/3/reference/datamodel.html#special-method-names
- Spark集群搭建中的问题
参照<Spark实战高手之路>学习的,书籍电子版在51CTO网站 资料链接 Hadoop下载[链接](http://archive.apache.org/dist/hadoop/core/ ...
- 好的 小图标 html
只需引用样式,加入字体文件到项目中就可实现 <link href="css/font-awesome.min.css" rel="stylesheet"& ...
- 基于IDL 的WebRS系统设计图
图1 用例图 图2 结构图