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 ...
随机推荐
- sql关键字过滤C#方法
/// <summary> ///SQL注入过滤 /// </summary> /// <param name="InText">要过滤的字符串 ...
- 错误 1 error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 C:\Users\Administ
错误 1 error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 C:\Users\Administ 这两个fatal error是因为从低版本的WTL到高版本的WTL转变后产生的 ...
- 软件开发常用的linux命令心得(ubuntu为例)
软件开发过程中难免要经常对主机进行配置或者部署等操作,想到一些就写一些了,以后再更新 解压命令: a.如果是tar文件,则直接用 “tar zxvf 文件名”: b.如果是zip文件,用 “unzip ...
- Dominating Patterns
Dominating Patterns Time Limit:3000MS Memory Limit:Unknown 64bit IO Format:%lld & %llu Descr ...
- Games on a CD
Games on a CD time limit per test 4 seconds memory limit per test 512 megabytes input standard input ...
- iOS开发工具——统计Crash的工具Crashlytics
简介 Crashlytic 成立于2011年,是专门为移动应用开者发提供的保存和分析应用崩溃信息的工具.Crashlytics的使用者包括:支付工具Paypal, 点评应用Yelp, 照片分享应用Pa ...
- Android Camera(二)
上次已经写过SurfaceView显示Camera摄像了,代码可以运行,但是里面有问题,这次纠正过来,顺便实现变焦: 代码: public class CameravedioActivity exte ...
- 使用Github搭建个人博客网站
1 新建一个repo,创建一个没有父节点的分支gh-pages(github规定,只有该分支中的页面,才会生成网页文件): mkdir jekyll_demo cd jekyll_demo git i ...
- IDL 实现 EOF(经验正交函数分析)
关于EOF详细介绍请wiki http://en.wikipedia.org/wiki/Empirical_orthogonal_functions或者Google之. 与PCA一样,EOF也是遥感多 ...
- int *p[4]与int (*q)[4]的区别
以上定义涉及两个运算符:“*”(间接引用).“[]”(下标),“[]”的优先级别大于“*”的优先级别. 首先看int *p[4],“[]”的优先级别高,所以它首先是个大小为4的数组,即p[4]:剩下的 ...