博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CF Zepto Code Rush 2014 B. Om Nom and Spiders
阅读量:6343 次
发布时间:2019-06-22

本文共 3933 字,大约阅读时间需要 13 分钟。

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.LR.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....RRLLUUUU
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.

水题,奸诈的放在了第二个。

AC代码例如以下:

#include
#include
#include
#include
#include
#define M 100005#define ll long longusing namespace std;char a[2005][2005];int main(){ int n,m,k; int i,j; int b[2005]; memset(b,0,sizeof b); scanf("%d%d%d",&n,&m,&k); for(i=0;i
=0) b[j-i]++; if(a[i][j]=='U') { if(i%2==0) b[j]++; } } for(i=0;i

转载地址:http://oskla.baihongyu.com/

你可能感兴趣的文章
指纹获取 Fingerprint2
查看>>
SB阿里云,windows2012r2无法安装.net3.5
查看>>
函数的继承
查看>>
黑盒测试用例设计方法&理论结合实际 -> 场景法
查看>>
快速打开软件以及文件夹
查看>>
CSS选择符
查看>>
剑指offer---19--***-顺时针打印矩阵
查看>>
关于数组随机不重复的思路
查看>>
oracle赋值问题(将同一表中某一字段赋值给另外一个字段的语句)
查看>>
Windows 安装 Jenkins 2.6
查看>>
计算一个点是否在一个区域中
查看>>
正则表达式
查看>>
淘宝面试题:有一个一亿节点的树,现在已知两个点,找这两个点的共同的祖先。...
查看>>
EntityFramework 6.x多个上下文迁移实现分布式事务
查看>>
高版本SQL备份在低版本SQL还原问题
查看>>
一键安装最新内核并开启 BBR 脚本
查看>>
C# 绘制图表(柱状图,线性图,饼状图)
查看>>
.NET中使用Redis
查看>>
PHP 页面跳转的三种方式
查看>>
Juniper总结
查看>>