标签:style http color os io for ar 代码
题意:在一个界面上有多个窗口,求没有被其他窗口覆盖的窗口的个数。
思路:直接暴力枚举每个窗口的长和宽,以确定右下角是否与左上角相同,如果相同再判断矩形内部有没有被其他窗口覆盖到,注意边界覆盖也是算被覆盖到。
代码:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 105; char g[MAXN][MAXN]; int n, m, vis[30]; int judge(int x1, int y1, int x2, int y2) { for (int i = x1; i <= x2; i++) { for (int j = y1; j <= y2; j++) { if (isupper(g[i][j])) { if (g[i][j] != g[x1][y1]) return 0; } } } return 1; } void solve() { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (isupper(g[i][j])) { int a = j, b = i; while (g[i][a + 1] == g[i][j]) { a++; } while (g[b + 1][j] == g[i][j]) { b++; } if (b - i < 2 || a - j < 2) continue; if (g[b][a] == g[i][j] && judge(i, j, b, a)) vis[g[i][j] - 'A'] = 1; } } } } int main() { while (scanf("%d%d", &n, &m) && n && m) { memset(vis, 0, sizeof(vis)); for (int i = 0; i < n; i++) scanf("%s", g[i]);; solve(); for (int i = 0; i < 30; i++) if (vis[i]) printf("%c", i + 'A'); printf("\n"); } return 0; }
1419 - Ugly Windows(暴力枚举),布布扣,bubuko.com
标签:style http color os io for ar 代码
原文地址:http://blog.csdn.net/u011345461/article/details/38638795