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. 启明星会议室预定系统Outlook版开始支持Exchange2013与Office365版

    版本启明星会议室预定系统支持Exchange2013与微软云服务Office365版.(注意:Exchange2007与Exchange2010也适合此版本) 1.安装 首页,安装类似启明星普通的会议 ...

  2. mybatis映射文件遇到的小问题

    mybatis的映射文件插入操作时: 如果对应的属性是String类型的,那么一定要做空串的判断. 比如注册的时候,如果需要向数据库中插入一条记录时,对应的字段没有给他赋值,这个String类型的值传 ...

  3. 使用Java、Matlab画多边形闭合折线图

    由于写论文要将“哈密顿回路问题(TSP)”的求解中间结果表示出来,查了一下使用程序画多边形图形.现在在总结一下,这个图是“由给定节点首尾相连的”闭合多边形. 1.使用matlab作闭合多边形图 没有找 ...

  4. Linux系统教程 标准输入/输出和重定向

    1. 标准输入与输出 我们知道,执行一个shell命令行时通常会自动打开三个标准文件,即标准输入文件(stdin),通常对应终端的键盘:标准输出文件(stdout)和标准错误输出文件(stderr), ...

  5. Cesium中Homebutton改变默认跳转位置 【转】

    在Cesium中,Homebutton的默认跳转位置是美国,那么在开发中我们如何更改这个默认跳转位置呢,这就要更改一下源代码了: Camera.DEFAULT_VIEW_RECTANGLE = Rec ...

  6. graphic rendering pipeline

    整理下管线 此时一定要有这张图 注意表中的数据流向 强调几个细节 之前对次序理解有点乱 rasterizer之前 管线里是只有逐顶点信息的 IA里面会setup primitive  通过Primit ...

  7. Android GUI之View布局

    在清楚了View绘制机制中的第一步测量之后,我们继续来了解分析View绘制的第二个过程,那就是布局定位.继续跟踪分析源码,根据之前的流程分析我们知道View的绘制是从RootViewImpl的perf ...

  8. HDOJ-3785 寻找大富翁(优先队列)

    寻找大富翁 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  9. Android -- 重置Bitmap大小&&Bitmap转角度

    重置Bitmap大小                                                                           Bitmap bitMap = ...

  10. 如何开机就启动node.js程序

      npm install -g qckwinsvc 定位到安装目录,node_modules/.bin/ 运行如下命令: > qckwinsvc prompt: Service name: [ ...