题目链接:https://vjudge.net/contest/398579#problem/B 题解:因为只有R和D,所以最后一定会到达最右边一列,或者最下边一行。所以只需要统计这两行即可。 代码:
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<string>
#define maxn 120
using namespace std
;
typedef long long ll
;
string s
[maxn
];
int main()
{
int n
;
int m
,t
;
scanf("%d",&t
);
while(t
--)
{
int ans
=0;
scanf("%d%d",&n
,&m
);
for(int i
=0;i
<n
;i
++)
cin
>>s
[i
];
for(int i
=0;i
<n
;i
++)
if(s
[i
][m
-1]=='R')
ans
++;
for(int i
=0;i
<m
;i
++)
if(s
[n
-1][i
]=='D')
ans
++;
cout
<<ans
<<endl
;
}
return 0;
}
转载请注明原文地址:https://blackberry.8miu.com/read-18177.html