纯属练习JAVA....

B. Om Nom and Spiders
time limit per test

3 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Om Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to see them at all.

The park can be represented as a rectangular n × m field. The park has k spiders, each spider at time 0 is at some cell of the field. The spiders move all the time, and each spider always moves in one of the four directions (left, right, down, up). In a unit of time, a spider crawls from his cell to the side-adjacent cell in the corresponding direction. If there is no cell in the given direction, then the spider leaves the park. The spiders do not interfere with each other as they move. Specifically, one cell can have multiple spiders at the same time.

Om Nom isn't yet sure where to start his walk from but he definitely wants:

  • to start walking at time 0 at an upper row cell of the field (it is guaranteed that the cells in this row do not contain any spiders);
  • to walk by moving down the field towards the lowest row (the walk ends when Om Nom leaves the boundaries of the park).

We know that Om Nom moves by jumping. One jump takes one time unit and transports the little monster from his cell to either a side-adjacent cell on the lower row or outside the park boundaries.

Each time Om Nom lands in a cell he sees all the spiders that have come to that cell at this moment of time. Om Nom wants to choose the optimal cell to start the walk from. That's why he wonders: for each possible starting cell, how many spiders will he see during the walk if he starts from this cell? Help him and calculate the required value for each possible starting cell.

Input

The first line contains three integers n, m, k (2 ≤ n, m ≤ 2000; 0 ≤ k ≤ m(n - 1)).

Each of the next n lines contains m characters — the description of the park. The characters in the i-th line describe the i-th row of the park field. If the character in the line equals ".", that means that the corresponding cell of the field is empty; otherwise, the character in the line will equal one of the four characters: "L" (meaning that this cell has a spider at time 0, moving left), "R" (a spider moving right), "U" (a spider moving up), "D" (a spider moving down).

It is guaranteed that the first row doesn't contain any spiders. It is guaranteed that the description of the field contains no extra characters. It is guaranteed that at time 0 the field contains exactly k spiders.

Output

Print m integers: the j-th integer must show the number of spiders Om Nom will see if he starts his walk from the j-th cell of the first row. The cells in any row of the field are numbered from left to right.

Sample test(s)
input
3 3 4
...
R.L
R.U

output
0 2 2 

input
2 2 2
..
RL

output
1 1 

input
2 2 2
..
LR

output
0 0 

input
3 4 8
....
RRLL
UUUU

output
1 3 3 1 

input
2 2 2
..
UU

output
0 0 

Note

Consider the first sample. The notes below show how the spider arrangement changes on the field over time:

...        ...        ..U       ...
R.L   ->   .*U   ->   L.R   ->  ...
R.U        .R.        ..R       ...

Character "*" represents a cell that contains two spiders at the same time.

  • If Om Nom starts from the first cell of the first row, he won't see any spiders.
  • If he starts from the second cell, he will see two spiders at time 1.
  • If he starts from the third cell, he will see two spiders: one at time 1, the other one at time 2.
import java.util.*;public class Main
{public static void main(String[] args){Scanner cin=new Scanner(System.in);int n=cin.nextInt(),m=cin.nextInt(),k=cin.nextInt();String[] mp=new String[n];for(int i=0;i<n;i++)mp[i]=cin.next();int[] ans=new int[m];for(int i=0;i<n;i++){for(int j=0;j<m;j++){char c=mp[i].charAt(j);if(c=='U'){if(i%2==0)ans[j]++;}else if(c=='R'){int t=i+j;if(t<m)ans[t]++;}else if(c=='L'){int t=j-i;if(t>=0)ans[t]++;}}}StringBuilder RET=new StringBuilder();for(int i=0;i<m;i++){RET.append(ans[i]+" ");}System.out.println(RET);}
}

Codefoces 436 B. Om Nom and Spiders相关推荐

  1. B. Om Nom and Dark Park

    B. Om Nom and Dark Park 在满二叉树上的某些边上添加一些值.使得根节点到叶子节点的路径上的权值和都相等.求最少需要添加多少. 我们利用性质解题.   考察兄弟节点.由于他们从跟节 ...

  2. 【Henu ACM Round#19 E】 Om Nom and Candies

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 紫书上的原题: 链接 [代码] #include <bits/stdc++.h> #define ll long lon ...

  3. 关于上传文件的跨域问题

    在进行新框架开发的过程中,需要自定义页面组件实现脱离表单的文件(图片)上传,考虑过wex5自带的attachmentsimple的自定义写法很难受,就改用了第三方插件webuploader来实现选择文 ...

  4. 《为iPad而设计:打造畅销App》——想象iPad上的游戏

    本节书摘来自异步社区<为iPad而设计:打造畅销App>一书中的想象iPad上的游戏,作者[英]Chris Stevens,更多章节内容可以访问云栖社区"异步社区"公众 ...

  5. 世界顶级音效公司_世界顶级游戏开发公司

    世界顶级音效公司 The game industry is growing, especially among small, independent development companies. If ...

  6. Practice II 字符串

    本来想做数论的--但是别的dalao都在做制胡窜 所以-- Chapter I KMP KMP 最关键的不是这个半暴力的单模匹配 而是这个nxt数组 经常出一些奇怪的题 尤其是循环节可以直接由T-nx ...

  7. HTTP 头部字段 Access-Control-Allow-Origin

    前后端分离的协作开发方式,已经被很多公司采用.若前后端部署在不同的域名下,就会碰到跨域的问题.对于跨域的问题,W3C 有标准的解决方案,即跨域资源共享(Cross-origin resource sh ...

  8. web前端研发工具篇

    web前端研发工具篇 一.常见前端开发IDE 1.Visual Studio Code 2.hbuilder 3.sublime text3 4.WebStorm 5.Atom 6.Dreamweav ...

  9. 移动游戏开发商50强(世界)

    http://media.cocoachina.com/pg-global-mobile-developers-top-10-1/ 在2012年的榜单揭晓之前,先让我们回顾一下2011年的10强吧. ...

最新文章

  1. 【图论技巧】点边转化(拆点和拆边)
  2. 神经尘埃、脑波打字…… 2018年的脑科学要研究什么?
  3. wxPython笔记
  4. WordPress上传大小限制问题
  5. Android Studio 如何导入第三方jar包(整理)
  6. 【PAT甲级 LinkedHashMap】1041 Be Unique (20 分) Java、C++版
  7. 可以直视烤箱里面的食物吗?
  8. 说明一项最有成就感的php项目,2020 Github 上 10 个最受欢迎的 PHP 项目
  9. linux操作系统好吗_国内可以通过安卓+termux打造出适用手机平板和电脑全平台最好的操作系统...
  10. java学习-BeanUtils给对象的属性赋值
  11. mpacc和计算机硕士,考MPAcc还是工作?读研三年VS工作三年对比!
  12. c oracle 参数赋值,利用c#反射实现实体类生成以及数据获取与赋值
  13. MATLAB在声学理论基础中的应用,MATLAB在声学理论基础中的应用
  14. 联想三大业务收入下滑,刘军回归能重振业绩吗
  15. JavaScript基础知识总结(必看篇)
  16. foxmail客户端设置网易邮箱--提示邮箱地址或密码错误
  17. Java实现IP代理
  18. Docker 问题集锦(19) - 解决:standard_init_linux.go:219: exec user process caused
  19. fractional cascading
  20. 史上首例!阿里程序员写的代码,被国家博物馆收藏了!

热门文章

  1. linux 允许ssl采用中强度加密_彻底搞清HTTPS安全通讯之SSL/TLS加密协议
  2. 翻译mosHow to Switch to a New Undo Tablespace (文档 ID 1951695.1)使用新的undo表空间和删除旧的表空间
  3. MySql中设置时区为东八区
  4. harmonyos公测版v2.0安装,HarmonyOS2.0Beta版本-HarmonyOS2.0Beta官方版本安装预约 v1.0.0-优盘手机站...
  5. MATLAB生成单位矩阵、三角矩阵、零矩阵、1矩阵
  6. 初探netCDF4——ECMWF学习笔记
  7. matlab svc,基于MATLAB的SVC抑制SSR仿真研究
  8. 缺省的servlet
  9. 中小企业用户该如何选择云服务器?阿里,腾讯,还是华为云?
  10. 深入浅出matplotlib(64): 绘制矢量流线图