poj3923:http://poj.org/problem?id=3923

题意:给出两个整数n、m表示屏幕的长宽。屏幕上有一些窗口,每个窗口都是矩形的,窗口的边框用同一个大写字母来表示,不同的窗口的大写字母必定不同。

由于窗口的重叠,有些窗口的有些部分被其他窗口覆盖。但是,肯定有一些窗口在最顶端,不被其他任何窗口覆盖。我们称这些窗口为“顶端窗口”。你的任务就是找出所有的顶端窗口。

题解:简单的模拟。结果我错了很多次啊。首先,没有考虑到边框的内部一定要是'.',然后是最坑就是每个窗口的高度和宽度都不能小于3,自己模拟能力还是很弱啊,要多打打。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
bool visit[],ans[];
char mp[][];
struct Node{
int x1,y1;
int x2,y2;
}num[];
int n,m;
int main(){
while(~scanf("%d%d",&n,&m)){
if(n==&&m==)break;
if(n<||m<)continue;
memset(visit,,sizeof(visit));
memset(num,,sizeof(num));
memset(mp,,sizeof(mp));
memset(ans,,sizeof(ans));
for(int i=;i<=;i++){
num[i].x1=num[i].y1=;
num[i].x2=num[i].y2=;
}
for(int i=;i<=n;i++)
for(int j=;j<=m;j++){
cin>>mp[i][j];
if(mp[i][j]!='.'){
num[mp[i][j]-'A'].x1=min(num[mp[i][j]-'A'].x1,i);
num[mp[i][j]-'A'].y1=min(num[mp[i][j]-'A'].y1,j);
num[mp[i][j]-'A'].x2=max(num[mp[i][j]-'A'].x2,i);
num[mp[i][j]-'A'].y2=max(num[mp[i][j]-'A'].y2,j);
visit[mp[i][j]-'A']=;
}
}
for(int i=;i<=;i++){
if(visit[i]){
int t1=num[i].x1;
int t2=num[i].y1;
int t3=num[i].x2;
int t4=num[i].y2;
bool flag=false;
for(int j=t2;j<=t4;j++){
if((mp[t1][j]!=('A'+i))||(mp[t3][j]!=('A'+i))){
flag=true;
break;
}
}
for(int j=t1;j<=t3;j++){
if(mp[j][t2]!=('A'+i)||mp[j][t4]!=('A'+i)){
flag=true;
break;
}
}
if(t3-t1<||t4-t2<)flag=true;
if(!flag)
ans[i]=;
}
}
for(int i=;i<=;i++){
if(visit[i]){
for(int k=num[i].x1+;k<num[i].x2;k++){
for(int j=num[i].y1+;j<num[i].y2;j++){
if(mp[k][j]!='.')
ans[i]=;
}
}
}
}
for(int i=;i<=;i++)
if(ans[i])
printf("%c",i+'A');
printf("\n");
}
}

Ugly Windows的更多相关文章

  1. POJ 3923 HDU 2487 Ugly Windows 简单计算

    Ugly Windows Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tot ...

  2. HDU 2487 Ugly Windows(暴力)(2008 Asia Regional Beijing)

    Description Sheryl works for a software company in the country of Brada. Her job is to develop a Win ...

  3. HDU 2487 Ugly Windows

    递归求解,代码不太好看,是2013年7月写的 代码: #include<stdio.h> #include<iostream> #include<string.h> ...

  4. 【HDOJ】2487 Ugly Windows

    暴力解. #include <cstdio> #include <cstring> #define MAXN 105 char map[MAXN][MAXN]; ]; int ...

  5. POJ 3923 Ugly Windows(——考察思维缜密性的模拟题)

    题目链接: http://poj.org/problem?id=3923 题意描述: 输入一个n*m的屏幕 该屏幕内有至少一个对话框(每个对话框都有对应的字母表示) 判断并输出该屏幕内处于最表层的对话 ...

  6. windows下 cmd 界面的替代者 cmder 推荐!

    介绍 http://cmder.net/ Portable console emulator for Windows Cmder is a software package created out o ...

  7. HDUOJ----2487Ugly Windows

    Ugly Windows Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  8. 一起KVM环境下windows7虚拟机异常死机(BSOD)的问题解决

    先说一下环境: 一.硬件 8台服务器做的超融合架构,软件存储池, 每台服务器是96G内存,两颗Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz,32线程. 每台服务器是 ...

  9. HDU-2487

    Ugly Windows Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

随机推荐

  1. Memo打印1

              Delphi 打印Memo里面的内容 实现的功能和记事本的打印的功能一样 打印保存为文件时此时的文件名如何设置? 当Memo里的文本数量巨大时 窗体正在打印会出现点数字显示问题 闪 ...

  2. [Flux] 2. Overview and Dispatchers

    Flux has four major components: Stores, Dispatchers, Views, and Actions. These components interact l ...

  3. [React + webpack] hjs-webpack

    You can easily spend hours configuring the perfect dev environment with all the latest hotness like ...

  4. Android自定义drawable(Shape)详解

    在Android开发过程中,经常需要改变控件的默认样式, 那么通常会使用多个图片来解决.不过这种方式可能需要多个图片,比如一个按钮,需要点击时的式样图片,默认的式样图片. 这样就容易使apk变大. 那 ...

  5. Java基础知识强化之多线程笔记01:多线程基础知识(详见Android(java)笔记61~76)

    1. 基础知识: Android(java)学习笔记61:多线程程序的引入    ~    Android(java)学习笔记76:多线程-定时器概述和使用 

  6. python - 操作RabbitMQ

    python - 操作RabbitMQ     介绍 RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统.他遵循Mozilla Public License开源协议.MQ全称为Mess ...

  7. CakePHP的文章分类的功能实现

    前些天实现了[微个人.大家园]的文章文类功能.现在回忆一下,是如何完成的吧. 具体的操作步骤如下: 1.在文章posts表里添加一个列,category_id. 2.在数据库中添加一个数据表,cate ...

  8. iOS中JavaScript和OC交互

    转载自:http://www.devzeng.com/blog/ios-uiwebview-interaction-with-javascript.html 还可参考的文章:http://blog.c ...

  9. Windows 8 / 8.1 禁用驱动签名最详细图文教程

    Windows 8 鼠标右上角/右下角弹出边栏,选择“设置” 点击“更改电脑设置”: 选择“常规”,右侧拖到底,点击“高级启动”-“立即重启”: 稍后进入恢复页面,选择“疑难解答” 进入疑难解答后,选 ...

  10. Adapter 模式

    在实际软件系统设计和开发中,会经常遇到这种问题:我们为了完成某项工作购买了一个第三方的库来加快开发. 这就带来了一个问题: 我们在应用程序中已经设计好了接口,与这个第三方提供的接口不一致,为了使得这些 ...