Ugly Windows

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1199    Accepted Submission(s): 467

Problem 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 conservative. They even never use graphical monitors! So Sheryl’s operating system has to run in text mode and windows in that system are formed by characters. Sheryl decides that every window has an ID which is a capital English letter (‘A’ to ‘Z’). Because every window had a unique ID, there can’t be more than 26 windows at the same time. And as you know, all windows are rectangular.

On the screen of that ugly Windows system, a window’s frame is formed by its ID letters. Fig-1 shows that there is only one window on the screen, and that window’s ID is ‘A’. Windows may overlap. Fig-2 shows the situation that window B is on the top of window A. And Fig-3 gives a more complicated overlapping. Of course, if some parts of a window are covered by other windows, you can’t see those parts on the screen.

.........................
....AAAAAAAAAAAAA........
....A...........A........
....A...........A........
....A...........A........
....AAAAAAAAAAAAA........
.........................

Fig-1

.........................
....AAAAAAAAAAAAA........
....A...........A........
....A.......BBBBBBBBBB...
....A.......B........B...
....AAAAAAAAB........B...
............BBBBBBBBBB...
.........................

Fig-2

..........................
....AAAAAAAAAAAAA.........
....A...........A.........
....A.......BBBBBBBBBB....
....A.......B........BCCC.
....AAAAAAAAB........B..C.
.......C....BBBBBBBBBB..C.
.......CCCCCCCCCCCCCCCCCC. 
..........................

Fig-3

If a window has no parts covered by other windows, we call it a “top window” (The frame is also considered as a part of a window). Usually, the top windows are the windows that interact with user most frequently. Assigning top windows more CPU time and higher priority will result in better user experiences. Given the screen presented as Figs above, can you tell Sheryl which windows are top windows?

 
Input
The input contains several test cases.

Each test case begins with two integers, n and m (1 <= n, m <= 100), indicating that the screen has n lines, and each line consists of m characters.

The following n lines describe the whole screen you see. Each line contains m characters. For characters which are not on any window frame, we just replace them with ‘.’ .

The input ends with a line of two zeros.

It is guaranteed that:

1) There is at least one window on the screen.
2) Any window’s frame is at least 3 characters wide and 3 characters high.
3) No part of any window is outside the screen.

 
Output
For each test case, output the IDs of all top windows in a line without blanks and in alphabet order.
 
Sample Input
9 26 .......................... ....AAAAAAAAAAAAA......... ....A...........A......... ....A.......BBBBBBBBBB.... ....A.......B........BCCC. ....AAAAAAAAB........B..C. .......C....BBBBBBBBBB..C. .......CCCCCCCCCCCCCCCCCC. .......................... 7 25 ......................... ....DDDDDDDDDDDDD........ ....D...........D........ ....D...........D........ ....D...........D..AAA... ....DDDDDDDDDDDDD..A.A... ...................AAA... 0 0
 
Sample Output
B AD
 
Source
 
 
代码:

 #include<iostream>
#include<vector>
using namespace std;
const int maxn=;
const int NN=;
char win[NN][NN];
typedef struct windows
{
int x,y;
}ww;
int n,m;
void work()
{
int min_x,max_x,min_y,max_y,i,j;
char ch;
vector<ww>aa;
ww temp;
for(ch='A'; ch<='Z';ch++)
{
aa.clear();
min_x=min_y=maxn;
max_x=max_y=;
for(i=;i<n;i++) //---> y
{
for(j=;j<m;j++) //--->x
{
if(ch==win[i][j]) //这样就存储了一个图
{
temp.x=j+;
temp.y=i+;
aa.push_back(temp);
}
} }
/*华丽丽的分割线对这个图进行分析找到他的四个极点*/
if(aa.size()==) continue ; //说明没有这个windows
for(i= ;i<aa.size();i++ )
{
if(max_x<aa[i].x) max_x=aa[i].x;
if(max_y<aa[i].y) max_y=aa[i].y;
if(min_x>aa[i].x) min_x=aa[i].x;
if(min_y>aa[i].y) min_y=aa[i].y;
}
if((max_x-min_x)<||(max_y-min_y)<||*(max_x-min_x+max_y-min_y)!=aa.size()) continue;
bool tag=false;
for(i=min_y;i<(max_y-);i++)
{
for(j=min_x;j<(max_x-);j++)
{
if(win[i][j]>='A'&&win[i][j]<='Z') //判断是否在在框内有顶点框
{
tag=true;
goto loop;
}
}
}
loop:
if(!tag) cout<<ch;
}
cout<<endl;
}
int main()
{
// int n,m;
int i,j;
while(cin>>n>>m,n+m)
{ for( i= ; i<n ; i++ )
{
for( j= ; j<m ; j++)
cin>>win[i][j];
} work();
}
return ;
}

HDUOJ----2487Ugly Windows的更多相关文章

  1. HDU 3966 /// 树链剖分+树状数组

    题意: http://acm.hdu.edu.cn/showproblem.php?pid=3966 给一棵树,并给定各个点权的值,然后有3种操作: I x y z : 把x到y的路径上的所有点权值加 ...

  2. Windows server 2012 添加中文语言包(英文转为中文)(离线)

    Windows server 2012 添加中文语言包(英文转为中文)(离线) 相关资料: 公司环境:亚马孙aws虚拟机 英文版Windows2012 中文SQL Server2012安装包,需要安装 ...

  3. Windows Server 2012 NIC Teaming介绍及注意事项

    Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...

  4. C# 注册 Windows 热键

    闲扯: 前几日,一个朋友问我如何实现按 F1 键实现粘贴(Ctrl+V)功能,百度了一个方法,发给他,他看不懂(已经是 Boss 的曾经的码农),我就做了个Demo给他参考.今日得空,将 Demo 整 ...

  5. Windows 7上执行Cake 报错原因是Powershell 版本问题

    在Windows 7 SP1 电脑上执行Cake的的例子 http://cakebuild.net/docs/tutorials/getting-started ,运行./Build.ps1 报下面的 ...

  6. 在离线环境中发布.NET Core至Windows Server 2008

    在离线环境中发布.NET Core至Windows Server 2008 0x00 写在开始 之前一篇博客中写了在离线环境中使用.NET Core,之后一边学习一边写了一些页面作为测试,现在打算发布 ...

  7. Windows平台分布式架构实践 - 负载均衡

    概述 最近.NET的世界开始闹腾了,微软官方终于加入到了对.NET跨平台的支持,并且在不久的将来,我们在VS里面写的代码可能就可以通过Mono直接在Linux和Mac上运行.那么大家(开发者和企业)为 ...

  8. dll文件32位64位检测工具以及Windows文件夹SysWow64的坑

    自从操作系统升级到64位以后,就要不断的需要面对32位.64位的问题.相信有很多人并不是很清楚32位程序与64位程序的区别,以及Program Files (x86),Program Files的区别 ...

  9. 在docker中运行ASP.NET Core Web API应用程序(附AWS Windows Server 2016 widt Container实战案例)

    环境准备 1.亚马逊EC2 Windows Server 2016 with Container 2.Visual Studio 2015 Enterprise(Profresianal要装Updat ...

  10. 1.初始Windows Server 2012 R2 Hyper-V + 系统安装详细

    干啥的?现在企业服务器都是分开的,比如图片服务器,数据库服务器,redis服务器等等,或多或少一个网站都会用到多个服务器,而服务器的成本很高,要是动不动采购几十台,公司绝对吃不消的,于是虚拟化技术出来 ...

随机推荐

  1. easyui input设置为disabled提交后获取不到属性值

    在做网站管理后台的用户修改功能时,由于当前用户修改个人信息时规定用户名不能修改,故使用了input标签的disabled属性,但是在提交数据后却发现用户名显示为空了.后 来一查才知道input设置为d ...

  2. 点云数据(point cloud) 【转】

    转自caimagic的专栏 一:什么是点云数据 点云数据是指在一个三维坐标系统中的一组向量的集合.这些向量通常以X,Y,Z三维坐标的形式表示,而且一般主要用来代表一个物体的外表面形状.不经如此,除(X ...

  3. Evaluate Reverse Polish Notation leetcode java

    题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are + ...

  4. Math Number 数值类 包装类 数学计算 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  5. $.jsonp()的简单使用

    // jsonp 获取 json 数据: $.jsonp({ url: GLOBAL.baseUrl + '/company/mobi_getposter.action', callback: 'ca ...

  6. cocos2dx游戏存储举例及其注意事项

    今天白白跟大家分享一下cocos2dx中游戏的存储及需要注意的事项 cocos2dx中自带了存储类:CCUserDefault ,倘若需要存储的数据量教大的话,建议使用数据库来存储 现在先给大家看一下 ...

  7. TypeError: 'newline' is an invalid keyword argument for this function 错误解决

    出错代码: outputFile = open('output1.csv', 'w', newline='') # error line outputWriter = csv.writer(outpu ...

  8. 菜鸟运维笔记:小记编译安装Nginx所遇到的坑

    转载请注明出处:http://blog.csdn.net/guodongxiaren/article/details/40950249 谢谢合作 前言 无论是CentOS,或是Debian/Ubunt ...

  9. 算法笔记_176:历届试题 最大子阵(Java)

    目录 1 问题描述 2 解决方案   1 问题描述 问题描述 给定一个n*m的矩阵A,求A中的一个非空子矩阵,使这个子矩阵中的元素和最大. 其中,A的子矩阵指在A中行和列均连续的一块. 输入格式 输入 ...

  10. TP3.2 APP_DEBUG=false关闭调试后访问不了。页面错误!请稍后再试~

    在APP_DEBUG=true时是没问题的,在APP_DEBUG=false时才会出现找不到模板的问题.  经过排查可能是模板文件找不到问题,之前是这么写的. 改为这个就好了. ----------- ...