Responsive image

问题 2022 --B The lawn mower

2022: B The lawn mower

时间限制: 1 Sec  内存限制: 128 MB
提交: 3  解决: 2
[提交][状态][讨论版][命题人:]

题目描述

There is an n*m plot of land, each plot is either overgrown with weeds (represented by 
'W') or empty (represented by 'G'), and now there is a man standing at (1,1), facing 
(1,m), who can move in the following two ways:

1. It takes 1 unit of time to move one grid in the direction facing
2, move down one grid, and reverse the direction of the face (right to left, left to right), 
spend 1 unit of time
Now he wants to know the minimum number of units of time it takes to remove all the weeds (no need to return (1,1))

输入描述

The first line n, m

The next n rows represent the matrix as a string in each row.

n,m < = 150

输出描述

An integer in a row represents the answer.

样例输入

4 5
GWGGW
GGWGG
GWGGG
WGGGG

样例输出

11

来源

 

[提交][状态]
ACM算法攻关部
  • Anything about this OnlineJudge, Please Contact Administrator. Click add QQ

    OJ system based on HUSTOJ Project , UI based on Twitter Bootstrap

    Copyright 2016 ACM算法攻关部
    关于网站改版