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 ...
随机推荐
- Ansible3:ansible.cfg配置说明【转】
Ansible默认安装好后有一个配置文件/etc/ansible/ansible.cfg,该配置文件中定义了ansible的主机的默认配置部分,如默认是否需要输入密码.是否开启sudo认证.actio ...
- wpf资源嵌套,一个资源引用另外一个资源,被引用的资源应该声明在前面
在wpf的XAML的Window.Resources中,一个资源引用另外一个资源,出现如下错误: “错误 1 “{DependencyProperty.UnsetValue}”不是 Setter 上“ ...
- Stammering Aliens
Stammering Aliens Time Limit: 2000MS Memory Limit: 65536K Description Dr. Ellie Arroway has ...
- HDU 1155 Bungee Jumping 物理
题目大意:给出k:绳子的劲度系数,l:绳长,s:桥高,w:邦德的质量,g取9.81.绳子弹力=形变量*劲度系数.如果落地速度大于10 则摔死,小于0则飘着空中. 题目思路:根据能量守恒得知:落地的动能 ...
- php 批量导入数据的一种思维
<?php $str="风湿免疫科 消化内科 内分泌科 神经内科 感染内科 心血管内科放疗中心";$arr=explode(' ',$str);$sql="&quo ...
- Hbase shell 中能否通过filter实现的高级查询
import org.apache.hadoop.hbase.filter.CompareFilter import org.apache.hadoop.hbase.filter.SingleColu ...
- UVALive 2403 77377解题报告(深搜)
题意:给你一些固定的字符串,在给出数字,根据键盘的对应关系,输出所有的满足条件的字符串,输出顺序无所谓. 思路:因为题目说了,输出比较小,说明测试数据并不强,所以可以暴力回溯求出答案,将所有的给出的字 ...
- Bootstrap学习 - 全局CSS样式
栅格Grid <!-行(row)”必须包含在 .container (固定宽度)或 .container-fluid (100% 宽度)中-> <div class="c ...
- Mysql笔记4数据表操作1
1查看表的结构 (1)show create table +数据库名称 (2)desc+数据库名称 2修改表 (1)表中添加列 alter table 数据库名称 add column addr va ...
- c++ data语意学
Data Member的绑定 extern float x; class Point3d { public: point3d(); //问题:被传回和被设定的x是哪一个x呢? float X() c ...