-
Notifications
You must be signed in to change notification settings - Fork 0
/
1391B-Fix You.java
37 lines (32 loc) · 929 Bytes
/
1391B-Fix You.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.Scanner;
public class FixYou {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while (t-- > 0) {
int x = 0;
int y = 0;
int n = s.nextInt();
int m = s.nextInt();
char arr[][] = new char[n][m];
for (int i = 0; i < n; i++) {
String row = s.next();
for (int j = 0; j < m; j++) {
arr[i][j] = row.charAt(j);
}
}
for (int i = 0; i < m; i++) {
if (arr[n - 1][i] == 'D') {
x++;
}
}
for (int j = 0; j < n; j++) {
if (arr[j][m - 1] == 'R') {
y++;
}
}
int c = x + y;
System.out.println(c);
}
}
}