-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1388.cpp
More file actions
61 lines (52 loc) · 1.05 KB
/
Copy path1388.cpp
File metadata and controls
61 lines (52 loc) · 1.05 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
#include <iostream>
using namespace std;
int main() {
int width, height;
cin >> height >> width;
char** arr = new char* [height];
for (int i = 0; i < height; i++) {
arr[i] = new char[width];
}
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
cin >> arr[i][j];
}
}
int count = 0;
for (int i = 0; i < height - 1; i++) {
for (int j = 1; j < width; j++) {
if (arr[i][j] == '-') {
if (arr[i][j - 1] == '-') {
arr[i][j - 1] = '0';
count++;
}
}
else {
if (arr[i][j] == arr[i + 1][j]) {
arr[i][j] = '0';
count++;
}
}
}
}
for (int i = 1; i < height; i++) {
if (arr[i][0] == '|' && arr[i - 1][0] == '|') {
arr[i - 1][0] = '0';
count++;
}
}
for (int i = 1; i < width; i++) {
if (arr[height - 1][i] == '-' && arr[height - 1][i - 1] == '-') {
arr[height - 1][i - 1] = '0';
count++;
}
}
/*cout << endl << endl;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
cout << arr[i][j];
}
cout << endl;
}*/
cout << width * height - count;
}