博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Cf436B
阅读量:4309 次
发布时间:2019-06-06

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

/*A - Om Nom and SpidersTime Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64uSubmit Status Practice CodeForces 436BDescriptionOm 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.InputThe 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.OutputPrint 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 InputInput3 3 4...R.LR.UOutput0 2 2 Input2 2 2..RLOutput1 1 Input2 2 2..LROutput0 0 Input3 4 8....RRLLUUUUOutput1 3 3 1 Input2 2 2..UUOutput0 0 HintConsider 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.By Grant Yuan2014.7.11*/#include
#include
#include
#include
using namespace std;int n,m,k;char a[2005][2005];int b[2001];int main(){ cin>>n>>m>>k; memset(b,0,sizeof b); for(int i=0;i
=0) b[j-i]++; } for(int i=0;i

转载于:https://www.cnblogs.com/codeyuan/p/4254538.html

你可能感兴趣的文章
获取ServletContext
查看>>
七周成为数据分析师07_统计学基础
查看>>
变革之心
查看>>
IAP Store Kit Guide(中文)
查看>>
VS 2012 ASPX 页面编辑器的一点改进
查看>>
Python单元测试框架——unittest
查看>>
django序列化 serializers
查看>>
Centos7忘记root密码,修改root密码及其他用户密码
查看>>
删除数组指定的某个元素
查看>>
centos6.3 安装配置redis
查看>>
实现Callable接口。带返回值的线程
查看>>
一行代码将两个列表拼接出第三个列表(两个可迭代对象相加产生第三个可迭代对象)--map()方法...
查看>>
程序人口--MainFrame.java
查看>>
12-25造数据库面向对象
查看>>
web开发常见问题
查看>>
C++中namespace的使用
查看>>
非常好的Oracle教程【转】
查看>>
Java基础——安装及配置
查看>>
2017-03-05 CentOS中结合Nginx部署dotnet core Web应用程序
查看>>
并发与同步、信号量与管程、生产者消费者问题
查看>>