-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path[BOJ] 1652번.cpp
66 lines (60 loc) · 1.08 KB
/
[BOJ] 1652번.cpp
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
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int N, i, j, row, col, overlap;
char** condo;
int* row_spare;
int* col_spare;
int* row_overlap;
int* col_overlap;
row = 0;
col = 0;
cin >> N;
condo = new char*[N];
for (i = 0; i < N; i++)
condo[i] = new char[N];
row_spare = new int[N]();
col_spare = new int[N]();
row_overlap = new int[N]();
col_overlap = new int[N]();
for (i = 0; i < N; i++)
{
row_spare[i] = -1;
col_spare[i] = -1;
row_overlap[i] = -2;
col_overlap[i] = -2;
}
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
cin >> condo[i][j];
if (condo[i][j] == '.')
{
if (j - row_spare[i] > 1 && row_overlap[i] != row_spare[i])
{
row++;
row_overlap[i] = row_spare[i];
}
if (i - col_spare[j] > 1 && col_overlap[j] != col_spare[j])
{
col++;
col_overlap[j] = col_spare[j];
}
}
else
{
row_spare[i] = j;
col_spare[j] = i;
}
}
}
for (i = 0; i < N; i++)
delete[] condo[i];
delete[] condo;
delete[] row_spare;
delete[] col_spare;
cout << row << " " << col;
}