模拟,题意看了一小时

  1. /* ***********************************************
  2. Author :Zhou Zhentao
  3. Email :774388357@qq.com
  4. Created Time :2015/12/15 13:19:28
  5. File Name :main.cpp
  6. ************************************************ */
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <iostream>
  11. #include <algorithm>
  12. #include <vector>
  13. #include <queue>
  14. #include <set>
  15. #include <map>
  16. #include <string>
  17. #include <math.h>
  18. #include <stdlib.h>
  19. #include <time.h>
  20. using namespace std;
  21.  
  22. const int maxn=+;
  23. int Map[maxn][maxn];
  24. char s[+];
  25. int ans[+];
  26. int R,C,x,y;
  27.  
  28. bool P(int x,int y)
  29. {
  30. if(x>=&&x<=R)
  31. {
  32. if(y>=&&y<=C)
  33. {
  34. return ;
  35. }
  36. }
  37. return ;
  38. }
  39.  
  40. int main()
  41. {
  42. while(~scanf("%d%d",&R,&C))
  43. {
  44. memset(Map,,sizeof Map);
  45. scanf("%d%d",&x,&y);
  46. Map[x][y]=;
  47. ans[]=;
  48. scanf("%s",s);
  49. int len=strlen(s);
  50. for(int i=; i<len; i++)
  51. {
  52. if(i==len-)
  53. {
  54. int num=;
  55. for(int i=; i<=R; i++)
  56. {
  57. for(int j=; j<=C; j++)
  58. {
  59. if(Map[i][j]==) num++;
  60. }
  61. }
  62. ans[i+]=num;
  63. break;
  64. }
  65. else
  66. {
  67. int NewX,NewY;
  68. if(s[i]=='U')
  69. {
  70. NewX=x-;
  71. NewY=y;
  72. }
  73. else if(s[i]=='D')
  74. {
  75. NewX=x+;
  76. NewY=y;
  77. }
  78. else if(s[i]=='L')
  79. {
  80. NewX=x;
  81. NewY=y-;
  82. }
  83. else if(s[i]=='R')
  84. {
  85. NewX=x;
  86. NewY=y+;
  87. }
  88. if(P(NewX,NewY))
  89. {
  90. x=NewX;
  91. y=NewY;
  92. if(Map[NewX][NewY]==)
  93. {
  94. Map[x][y]=;
  95. ans[i+]=;
  96. }
  97. else ans[i+]=;
  98. }
  99. else ans[i+]=;
  100. }
  101. }
  102. for(int i=; i<=len; i++)
  103. {
  104. printf("%d",ans[i]);
  105. if(i<len) printf(" ");
  106. else printf("\n");
  107. }
  108. }
  109. return ;
  110. }

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. Ansible3:ansible.cfg配置说明【转】

    Ansible默认安装好后有一个配置文件/etc/ansible/ansible.cfg,该配置文件中定义了ansible的主机的默认配置部分,如默认是否需要输入密码.是否开启sudo认证.actio ...

  2. wpf资源嵌套,一个资源引用另外一个资源,被引用的资源应该声明在前面

    在wpf的XAML的Window.Resources中,一个资源引用另外一个资源,出现如下错误: “错误 1 “{DependencyProperty.UnsetValue}”不是 Setter 上“ ...

  3. Stammering Aliens

    Stammering Aliens Time Limit: 2000MS   Memory Limit: 65536K       Description Dr. Ellie Arroway has ...

  4. HDU 1155 Bungee Jumping 物理

    题目大意:给出k:绳子的劲度系数,l:绳长,s:桥高,w:邦德的质量,g取9.81.绳子弹力=形变量*劲度系数.如果落地速度大于10 则摔死,小于0则飘着空中. 题目思路:根据能量守恒得知:落地的动能 ...

  5. php 批量导入数据的一种思维

    <?php $str="风湿免疫科 消化内科 内分泌科 神经内科 感染内科 心血管内科放疗中心";$arr=explode(' ',$str);$sql="&quo ...

  6. Hbase shell 中能否通过filter实现的高级查询

    import org.apache.hadoop.hbase.filter.CompareFilter import org.apache.hadoop.hbase.filter.SingleColu ...

  7. UVALive 2403 77377解题报告(深搜)

    题意:给你一些固定的字符串,在给出数字,根据键盘的对应关系,输出所有的满足条件的字符串,输出顺序无所谓. 思路:因为题目说了,输出比较小,说明测试数据并不强,所以可以暴力回溯求出答案,将所有的给出的字 ...

  8. Bootstrap学习 - 全局CSS样式

    栅格Grid  <!-行(row)”必须包含在 .container (固定宽度)或 .container-fluid (100% 宽度)中-> <div class="c ...

  9. Mysql笔记4数据表操作1

    1查看表的结构 (1)show create table +数据库名称 (2)desc+数据库名称 2修改表 (1)表中添加列 alter table 数据库名称 add column addr va ...

  10. c++ data语意学

     Data Member的绑定 extern float x; class Point3d { public: point3d(); //问题:被传回和被设定的x是哪一个x呢? float X() c ...