forked from b-chae/AlgorithmStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1652.cpp
More file actions
75 lines (69 loc) · 1022 Bytes
/
Copy path1652.cpp
File metadata and controls
75 lines (69 loc) · 1022 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
using namespace std;
int N;
int board[100][100];
int ans1 = 0, ans2 = 0;
int main()
{
int i, j;
cin >> N;
for (i = 0; i < N; i++) {
string tmp;
cin >> tmp;
for (j = 0; j < N; j++) {
if (tmp[j] == '.') board[i][j] = 1;
else board[i][j] = 0;
}
}
for (i = 0; i < N; i++) {
int preNum = 0;
bool flag = false;
for (j = 0; j < N; j++) {
if (board[i][j] == 1) {
if (preNum == 1) {
flag = true;
}
else {
preNum = 1;
}
}
else {
preNum = 0;
if (flag) {
ans1 += 1;
flag = false;
}
}
}
if (flag) {
ans1 += 1;
flag = false;
}
}
for (i = 0; i < N; i++) {
int preNum = 0;
bool flag = false;
for (j = 0; j < N; j++) {
if (board[j][i] == 1) {
if (preNum == 1) {
flag = true;
}
else {
preNum = 1;
}
}
else {
preNum = 0;
if (flag) {
ans2 += 1;
flag = false;
}
}
}
if (flag) {
ans2 += 1;
flag = false;
}
}
cout << ans1 << " " << ans2;
}