-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCakeminator.java
More file actions
47 lines (40 loc) · 1.43 KB
/
Cakeminator.java
File metadata and controls
47 lines (40 loc) · 1.43 KB
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
38
39
40
41
42
43
44
45
46
47
/**
* Created by MalhotR1 on 11/30/2018.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Cakeminator {
public static void main(String[] args) throws IOException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
String[] in = br.readLine().trim().split(" ");
int rows = Integer.parseInt(in[0]);
int cols = Integer.parseInt(in[1]);
char[][] matrix = new char[rows][cols];
boolean[] rb = new boolean[rows];
boolean[] cb = new boolean[cols];
for (int i = 0; i < matrix.length; i++) {
matrix[i] = br.readLine().toCharArray();
}
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
if (matrix[i][j] == 'S') {
rb[i] = true;
cb[j] = true;
}
}
}
int totalrows = rows;
int totalcols = cols;
for (int i = 0; i < rb.length; i++) {
if (rb[i]) rows--;
}
for (int i = 0; i < cb.length; i++) {
if (cb[i]) cols--;
}
int count = rows * totalcols + cols * (totalrows - rows);
System.out.println(count);
}
}
}