-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1652.cpp
More file actions
77 lines (72 loc) · 1.02 KB
/
1652.cpp
File metadata and controls
77 lines (72 loc) · 1.02 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// 1652. 누울 자리를 찾아라
// 2019.05.18
// 수학
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n;
cin >> n;
string a[101];
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
// 가로 검사
int horizontal = 0;
// 가로로 누울 수 있는 자리
for (int i = 0; i < n; i++)
{
int cnt = 0;
for (int j = 0; j < n; j++)
{
if (a[i][j] == '.')
{
cnt++;
}
else if (a[i][j] == 'X' && cnt >= 2)
{
horizontal++;
cnt = 0;
}
else if (a[i][j] == 'X')
{
cnt = 0;
}
}
if (cnt >= 2)
{
horizontal++;
}
}
// 세로 검사
int vertical = 0;
// 세로로 누울 수 있는 자리
for (int i = 0; i < n; i++)
{
int cnt = 0;
for (int j = 0; j < n; j++)
{
if (a[j][i] == '.')
{
cnt++;
}
else if (a[j][i] == 'X' && cnt >= 2)
{
vertical++;
cnt = 0;
}
else if (a[j][i] == 'X')
{
cnt = 0;
}
}
if (cnt >= 2)
{
vertical++;
}
}
cout << horizontal << " " << vertical << endl;
return 0;
}