-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1236.cpp
More file actions
53 lines (49 loc) · 735 Bytes
/
Copy path1236.cpp
File metadata and controls
53 lines (49 loc) · 735 Bytes
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
48
49
50
51
52
53
// 1236. 성 지키기
// 2019.09.21
// 탐색
#include<iostream>
#include<algorithm>
using namespace std;
char map[51][51];
int col[51];
int row[51];
int main()
{
int x, y;
cin >> x >> y;
int cnt = 0;
for (int i = 0; i < x; i++)
{
for (int j = 0; j < y; j++)
{
cin >> map[i][j];
if (map[i][j] == 'X')
{
// 행과 열 체크
col[i] = true;
row[j] = true;
}
}
}
int cnt1 = 0;
int cnt2 = 0;
// 행이 보호가 되고 있는지 체크
for (int i = 0; i < x; i++)
{
if (!col[i])
{
cnt1++;
}
}
// 열이 보호가 되고 있는지 체크
for (int i = 0; i < y; i++)
{
if (!row[i])
{
cnt2++;
}
}
// 둘중 큰 값이 정답
cout << max(cnt1, cnt2) << endl;
return 0;
}