-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP201.cpp
78 lines (77 loc) · 1.41 KB
/
P201.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
67
68
69
70
71
72
73
74
75
76
77
78
int main() {
bool H[10][10], V[10][10];
int n, m, I, J;
string s;
for(int cas = 0; cin >> n >> m; ++cas) {
if(cas != 0)
cout << endl << "**********************************" << endl << endl;
cout << "Problem #" << cas+1 << endl << endl;
FORY(n) {
FORX(n) {
H[y][x] = V[y][x] = false;
}
}
FORI(m) {
cin >> s >> I >> J; --I; --J;
if(s[0] == 'V') {
H[I][J] = true;
}
else {
V[J][I] = true;
}
}
// Debug:
/*
FORY(n) {
FORX(n-1) {
if(H[y][x])
cerr << ".-";
else
cerr << ". ";
}
cerr << "." << endl;
if(y < n) {
FORX(n) {
if(V[y][x])
cerr << "| ";
else
cerr << " ";
}
}
cerr << endl;
}//*/
// Find all:
bool any = false;
for(int size = 1; size < n; ++size) {
int cnt = 0;
for(int y0 = 0; y0+size < n; ++y0) {
for(int x0 = 0; x0+size < n; ++x0) {
// Can I make the square:
bool ok = true;
FORI(size && ok) {
ok = H[y0][i+x0];
}
FORI(size && ok) {
ok = H[y0+size][i+x0];
}
FORI(size && ok) {
ok = V[y0+i][x0];
}
FORI(size && ok) {
ok = V[y0+i][x0+size];
}
if(ok) {
++cnt;
}
} // x0
} // y0
if(cnt > 0) {
any = true;
cout << cnt << " square (s) of size " << size << endl;
}
} // size
if(!any)
cout << "No completed squares can be found." << endl;
}
return 0;
}