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.

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

AC代码例如以下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define M 100005
#define ll long long
using 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<n;i++)
scanf("%s",a[i]);
for(i=1;i<n;i++)
for(j=0;j<m;j++)
{
if(a[i][j]=='R'&&i+j<m)//我认为i+j<m可有可无,可是他评我WA,还是加上吧
b[i+j]++;
if(a[i][j]=='L'&&j-i>=0)
b[j-i]++;
if(a[i][j]=='U')
{
if(i%2==0)
b[j]++;
}
}
for(i=0;i<m;i++)
printf("%d ",b[i]);
printf("\n");
return 0;
}

CF Zepto Code Rush 2014 B. Om Nom and Spiders的更多相关文章

  1. Zepto Code Rush 2014 B - Om Nom and Spiders

    注意题目给的是一个nxm的park,设元素为aij,元素aij 有4种可能U(上移),D(下移),L(左移),R(右移) 假设第i行第j列元素aij(注意元素的索引是从0开始的) 当aij为D时,此时 ...

  2. Codeforces - ZeptoLab Code Rush 2015 - D. Om Nom and Necklace:字符串

    D. Om Nom and Necklace time limit per test 1 second memory limit per test 256 megabytes input standa ...

  3. ZeptoLab Code Rush 2015 C. Om Nom and Candies 暴力

    C. Om Nom and Candies Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/526 ...

  4. ZeptoLab Code Rush 2015 B. Om Nom and Dark Park DFS

    B. Om Nom and Dark Park Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  5. ZeptoLab Code Rush 2015 C. Om Nom and Candies [ 数学 ]

    传送门 C. Om Nom and Candies time limit per test 1 second memory limit per test 256 megabytes input sta ...

  6. ZeptoLab Code Rush 2015 B. Om Nom and Dark Park

    Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who l ...

  7. Zepto Code Rush 2014 A. Feed with Candy

    此题用贪心求解, 首先将caramel drop类别的糖果按照高度从小到大排序,如果高度相同,按照重量从小到大排序 将fruit drop类别的糖果按照高度从小到大排序,如果高度相同,按照重量从小到大 ...

  8. Codeforces Zepto Code Rush 2014 -C - Dungeons and Candies

    这题给的一个教训:Codeforces没有超时这个概念.本来以为1000*(1000+1)/2*10*10要超时的.结果我想多了. 这题由于k层都可能有关系,所以建一个图,每两个点之间连边,边权为n* ...

  9. Zepto Code Rush 2014——Dungeons and Candies

    题目链接 题意: k个点,每一个点都是一个n * m的char型矩阵.对与每一个点,权值为n * m或者找到一个之前的点,取两个矩阵相应位置不同的字符个数乘以w.找到一个序列,使得全部点的权值和最小 ...

随机推荐

  1. POJ 2455Secret Milking Machine(二分+网络流之最大流)

    题目地址:POJ2455 手残真浪费时间啊..又拖到了今天才找出了错误..每晚两道题不知不觉又变回了每晚一道题...sad.. 第一次在isap中忘记调用bfs,第二次则是遍历的时候竟然是从1開始遍历 ...

  2. 3.1,pandas【基本功能】

    一:改变索引 reindex方法对于Series直接索引,对于DataFrame既可以改变行索引,也可以改变列索引,还可以两个一起改变. 1)对于Series In [2]: seri = pd.Se ...

  3. Linq 学习(1) 概述

    本篇简单回顾C#语言集合操作的变化,通过与Linq对等的面向对象的语法来认识Linq.Linq是Language Integrated Query, 初识Linq感觉跟SQL Server的Tsql很 ...

  4. oralce 恢复Delete删除

    select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual; select * from db_datatable as of timestam ...

  5. Oracle除去换行符的方法

    Oracle除去换行符的方法   很多数据存进数据库后,可能需要将整条数据取出,并用特殊 符号分割,而且整条数据必须是处于一行,如此,如果数据出现 换行的情况,那么读取时就有问题.     这个时候就 ...

  6. SVN—patch的应用

    svn 补丁的应用,在eclipse下有时候不能把全部变化加入,出现中文乱码问题.以下转载其他文章 原文地址:http://xiebh.iteye.com/blog/347458 1.create p ...

  7. UIImageView中最容易用错的属性UIContentMode小记

    UIContentMode这东西初学真是各种问题,只能不断尝试,偶然发现网上这张图片,做下记录 还有个UIViewContentModeRedraw,在使用这个设置后,每当图片的bounds就是大小或 ...

  8. c++回调实现

    回调是A将一个函数指针传给B,然后调用B,B在执行自身函数后,再在合适的时候执行A的这个函数指针,这样就能避免A和B的相互包含和链接,在大型项目中回调是一种打破循环依赖的常用技术. typedef v ...

  9. 用PHP删除文件操作unlink

    使用unlink要注意的是$filename的值,要用的是本地绝对地址.比如"c:\aaa\a.jpg",不能用相对地址比如:"../aa.jpg",那么如果在 ...

  10. storyboard和xib的区别

    storyboard只是算是帮你布局,流程什么的,xib的另一种形势,比xib功能多,但是和分享完全没有半点关系 你暂时可以理解为高级xib