【HDOJ】2487 Ugly Windows
标签:style blog color io for ar div amp
暴力解。
1 #include 2 #include 3
4 #define MAXN 105
5
6 char map[MAXN][MAXN];
7 char visit[27];
8 int n, m;
9
10 bool check(char c) {
11 int i, j;
12 int x1=MAXN, y1=MAXN, x2=-1, y2=-1;
13
14 for (i=0; ii) {
15 for (j=0; jj) {
16 if (map[i][j] == c) {
17 if (i i;
18 if (j j;
19 if (i>x2) x2 = i;
20 if (j>y2) y2 = j;
21 }
22 }
23 }
24 if (x2-x12 || y2-y12)
25 return false;
26 for (i=x1; ii)
27 if (map[i][y1]!=c || map[i][y2]!=c)
28 return false;
29 for (j=y1; jj)
30 if (map[x1][j]!=c || map[x2][j]!=c)
31 return false;
32 for (i=x1+1; ii)
33 for (j=y1+1; jj)
34 if (map[i][j] != ‘.‘)
35 return false;
36 return true;
37 }
38
39 int main() {
40 int i;
41 int j;
42
43 while (scanf("%d %d", &n, &m)!=EOF && (n||m)) {
44 memset(visit, false, sizeof(visit));
45 for (i=0; ii) {
46 scanf("%s", map[i]);
47 for (j=0; jj) {
48 if (map[i][j] != ‘.‘) {
49 visit[map[i][j]-‘A‘] = true;
50 }
51 }
52 }
53 for (i=0; i26; ++i) {
54 if (visit[i] && check(i+‘A‘))
55 printf("%c", i+‘A‘);
56 }
57 printf("\n");
58 }
59
60 return 0;
61 }
【HDOJ】2487 Ugly Windows,搜素材,soscw.com
【HDOJ】2487 Ugly Windows
标签:style blog color io for ar div amp
原文地址:http://www.cnblogs.com/bombe1013/p/3905875.html
评论