1419-ugly Windows (brute Force enumeration)

Source: Internet
Author: User

Topic links


Test Instructions: There are multiple windows on one interface, and the number of windows that are not covered by other windows.

Ideas: Direct violence enumerates the length and width of each window to determine if the lower-right corner is the same as the upper-left corner, and if the same again determines whether the inside of the rectangle is not covered by another window, note that the border overlay is also counted as overwritten.

code:

#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][y            1]) 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 < i++) if (Vis[i]) printf ("%c", i + ' A ');    printf ("\ n"); } return 0;}


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.