forked from ndb796/Fast_Campus_Algorithm_Lecture_Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path[08]_5.java
39 lines (30 loc) · 792 Bytes
/
[08]_5.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
38
39
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String input[] = sc.nextLine().split(" ");
int n = Integer.parseInt(input[0]);
int m = Integer.parseInt(input[1]);
char[][] data = new char[50][50];
int[] row = new int[50];
int[] column = new int[50];
for (int i = 0; i < n; i++) {
data[i] = sc.nextLine().toCharArray();
for (int j = 0; j < m; j++) {
if (data[i][j] == 'X') {
row[i] = 1;
column[j] = 1;
}
}
}
int row_count = 0;
for (int i = 0; i < n; i++) {
if (row[i] == 0) row_count++;
}
int column_count = 0;
for (int j = 0; j < m; j++) {
if (column[j] == 0) column_count++;
}
System.out.println(Math.max(row_count, column_count));
}
}