-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathUVA-201.cpp
67 lines (62 loc) · 1.13 KB
/
UVA-201.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
#include<cstdio>
#define MAXN 12
bool arrh[MAXN][MAXN];
bool arrv[MAXN][MAXN];
int n;
bool judge(int x,int y, int m) {
int i;
for(i=x;i<(x+m);++i) {
if(arrv[i][y] == false)
return false;
if(arrv[i][y+m] == false)
return false;
}
for(i=y;i<(y+m);++i) {
if(arrh[x][i] == false)
return false;
if(arrh[x+m][i] == false)
return false;
}
//printf("--- %d %d %d\n", x,y,m);
return true;
}
int squareNum(int m) {
int i,j,k=0;
for(i=1; i<=(n-m); ++i)
for(j=1; j<=(n-m); ++j)
if(judge(i, j, m))
++k;
return k;
}
int main() {
int m,i,j,k=0;
char c;
while(scanf("%d %d", &n, &m) == 2) {
for(i=1; i<=n; ++i)
for(j=1; j<=n; ++j) {
arrh[i][j] = false;
arrv[i][j] = false;
}
while(m--) {
scanf(" %c %d %d", &c, &i, &j);
if(c == 'H')
arrh[i][j] = true;
else
arrv[j][i] = true;
}
if(k!=0)
puts("\n**********************************\n");
printf("Problem #%d\n\n", ++k);
c = 0;
for(i=1; i<n; ++i) {
j = squareNum(i);
if(j != 0) {
c = 1;
printf("%d square (s) of size %d\n", j, i);
}
}
if(c == 0)
puts("No completed squares can be found.");
}
return 0;
}