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 ...
随机推荐
- 关于安卓HTTP请求用HttpUrlConnection还是HttpClient好
安卓和JAVA应用开发少不了要提交HTTP请求,而基本上目前有两个实现方式:HttpUrlConnection(即URL.openConnection)和HttpClient. 网上不少人都认为Htt ...
- tableView滚动的时候会 最后一行显示不完全的问题
问题可能原因 1:tableView高度的设置不正确,应该是屏幕的高度减去上面的高度(包括状态栏以及navigationBar的高度).正确设置了tableView的高度之后,才可以正常滚动到最后一行 ...
- jsp 页面取值
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- ios 贝塞尔画图
CGContextRef context = UIGraphicsGetCurrentContext(); //写文字 CGContextSetRGBFillColor(context, 1, 0, ...
- c++ map unordered_map
map operator<的重载一定要定义成const.因为map内部实现时调用operator<的函数好像是const. #include<string> #include& ...
- 获取Excel数据(或部分数据)并导出成txt文本格式
运行代码前先导入jxl架包,以下代码仅供参考: 测试excel文件(我要获取该excel的内容为省.县.乡.村.组和PH的值): ExcelTest01类代码如下: // 读取Excel的类 impo ...
- Cormen — The Best Friend Of a Man
Cormen — The Best Friend Of a Man time limit per test 1 second memory limit per test 256 megabytes i ...
- Converting between IEEE 754 and Float (Format related
The float can be converted to well known single-precision IEEE 754 number, why 754? It's the standar ...
- 最小点集覆盖=最大匹配<二分图>/证明
来源 最小点集覆盖==最大匹配. 首先,最小点集覆盖一定>=最大匹配,因为假设最大匹配为n,那么我们就得到了n条互不相邻的边,光覆盖这些边就要用到n个点. 现在我们来思考为什么最小点击覆盖一定& ...
- POJ2299--树状数组求逆序数
Description In this problem, you have to analyze a particular sorting algorithm. The algorithm proce ...