hdu 2487 Ugly Windows 模拟

#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
char map[110][110];
int n,m;
#define inf 100000
struct node
{
    int x,y;
};
vector <node> nn;
int main()
{
    while(1)
    {
        int i,j,k;
        scanf("%d%d",&n,&m);
        if(n==0) break;
        getchar();
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
                scanf("%c",&map[i][j]);
            getchar();
        }
        for(k=0;k<26;k++)
        {
            nn.clear();
            int maxx=0,maxy=0,minx=inf,miny=inf;
            char x=‘A‘+k;
            int flag=1;
            for(i=1;i<=n;i++)
                for(j=1;j<=m;j++)
                    if(map[i][j]==x)
                    {
                        node tmp;
                        tmp.x=i;
                        tmp.y=j;
                        nn.push_back(tmp);
                    }
            for(i=0;i<nn.size();i++)
            {
                if(nn[i].x>maxx) maxx=nn[i].x;
                if(nn[i].x<minx) minx=nn[i].x;
                if(nn[i].y>maxy) maxy=nn[i].y;
                if(nn[i].y<miny) miny=nn[i].y;
            }
            if(maxx<minx+2) continue;//printf("aaa");
            if(maxy<miny+2) continue;
            if(nn.size()!=(maxx-minx+maxy-miny)*2) flag=0;
            for(i=minx+1;i<maxx;i++)
                for(j=miny+1;j<maxy;j++)
                    if(isupper(map[i][j]))
                    {
                        flag=0;
                        break;
                    }
            if(flag) printf("%c",x);
        }
        printf("\n");
    }
    return 0;
}

hdu 2487 Ugly Windows 模拟

时间: 2024-10-05 04:58:25

hdu 2487 Ugly Windows 模拟的相关文章

POJ 3923 &amp; HDU 2487 Ugly Windows(模拟)

题目链接: PKU:http://poj.org/problem?id=3923 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2487 Description Sheryl works for a software company in the country of Brada. Her job is to develop a Windows operating system. People in Brada are incredibly cons

POJ 3923 &amp;amp; HDU 2487 Ugly Windows(模拟)

题目链接: PKU:http://poj.org/problem? id=3923 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2487 Description Sheryl works for a software company in the country of Brada. Her job is to develop a Windows operating system. People in Brada are incredibly con

HDU 2487 Ugly Windows

欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Ugly Windows Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1481    Accepted Submission(s): 591 Problem Description Sheryl works for a software company in the c

【HDOJ】2487 Ugly Windows

暴力解. 1 #include <cstdio> 2 #include <cstring> 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; i<n; ++i) { 15 for (j=0

hdu 3125 Slash(模拟)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3125 Problem Description The American English slash (/) is a punctuation mark. In the early modern period, in the Fraktur script, which was widespread through Europe in the Middle Ages, one slash(/) repr

Ugly Windows

poj3923:http://poj.org/problem?id=3923 题意:给出两个整数n.m表示屏幕的长宽.屏幕上有一些窗口,每个窗口都是矩形的,窗口的边框用同一个大写字母来表示,不同的窗口的大写字母必定不同. 由于窗口的重叠,有些窗口的有些部分被其他窗口覆盖.但是,肯定有一些窗口在最顶端,不被其他任何窗口覆盖.我们称这些窗口为“顶端窗口”.你的任务就是找出所有的顶端窗口. 题解:简单的模拟.结果我错了很多次啊.首先,没有考虑到边框的内部一定要是'.',然后是最坑就是每个窗口的高度和宽

hdu 1175 连连看(模拟循环队列)

连连看 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 18149    Accepted Submission(s): 4741 Problem Description "连连看"相信很多人都玩过.没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子.如果某两个相同的棋子,可以通过一条线连起来(这条

HDU 4608 I-number--简单模拟

I-number Time Limit: 5000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 The I-number of x is defined to be an integer y, which satisfied the the conditions below: 1.  y>x; 2.  the sum of each digit of y(under base 10) is the multiple of 10; 3.  among all

hdu 4831 Scenic Popularity(模拟)

题目链接:hdu 4831 Scenic Popularity 题目大意:略. 解题思路:对于休闲区g[i][0]和g[i][1]记录的是最近的两个景点的id(只有一个最近的话g[i][1]为0),对于景点来说,g[i][0]为-1(表示该id对应的是景点),g[i][1]为该景点的热度值.主要就是模拟,注意一些细节就可以了. #include <cstdio> #include <cstring> #include <cstdlib> #include <alg