HDUOJ----2487Ugly Windows
Ugly Windows
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1199 Accepted Submission(s): 467
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?
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.
#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的更多相关文章
- HDU 3966 /// 树链剖分+树状数组
题意: http://acm.hdu.edu.cn/showproblem.php?pid=3966 给一棵树,并给定各个点权的值,然后有3种操作: I x y z : 把x到y的路径上的所有点权值加 ...
- Windows server 2012 添加中文语言包(英文转为中文)(离线)
Windows server 2012 添加中文语言包(英文转为中文)(离线) 相关资料: 公司环境:亚马孙aws虚拟机 英文版Windows2012 中文SQL Server2012安装包,需要安装 ...
- Windows Server 2012 NIC Teaming介绍及注意事项
Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...
- C# 注册 Windows 热键
闲扯: 前几日,一个朋友问我如何实现按 F1 键实现粘贴(Ctrl+V)功能,百度了一个方法,发给他,他看不懂(已经是 Boss 的曾经的码农),我就做了个Demo给他参考.今日得空,将 Demo 整 ...
- Windows 7上执行Cake 报错原因是Powershell 版本问题
在Windows 7 SP1 电脑上执行Cake的的例子 http://cakebuild.net/docs/tutorials/getting-started ,运行./Build.ps1 报下面的 ...
- 在离线环境中发布.NET Core至Windows Server 2008
在离线环境中发布.NET Core至Windows Server 2008 0x00 写在开始 之前一篇博客中写了在离线环境中使用.NET Core,之后一边学习一边写了一些页面作为测试,现在打算发布 ...
- Windows平台分布式架构实践 - 负载均衡
概述 最近.NET的世界开始闹腾了,微软官方终于加入到了对.NET跨平台的支持,并且在不久的将来,我们在VS里面写的代码可能就可以通过Mono直接在Linux和Mac上运行.那么大家(开发者和企业)为 ...
- dll文件32位64位检测工具以及Windows文件夹SysWow64的坑
自从操作系统升级到64位以后,就要不断的需要面对32位.64位的问题.相信有很多人并不是很清楚32位程序与64位程序的区别,以及Program Files (x86),Program Files的区别 ...
- 在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 ...
- 1.初始Windows Server 2012 R2 Hyper-V + 系统安装详细
干啥的?现在企业服务器都是分开的,比如图片服务器,数据库服务器,redis服务器等等,或多或少一个网站都会用到多个服务器,而服务器的成本很高,要是动不动采购几十台,公司绝对吃不消的,于是虚拟化技术出来 ...
随机推荐
- synchronized与lock,哪个效率更高
Java在一开始就提供了synchronized关键字,用于多线程之间的同步.它使用简便,不会出现拿锁之后不归还的情况,可以避免一些编程错误. 而jdk5时提供的concurrent包里,有一个Loc ...
- SHA加密算法工具类
1.利用Apache的工具类实现加密: maven: <dependency> <groupId>commons-codec</groupId> <artif ...
- 关于JSONP以及跨域相关
什么是跨域: 浏览器对ajax请求的限制,不允许跨域请求资源. http://www.a.com--->http://www.b.com 是跨域 http://www.a.com-- ...
- 数据结构及算法篇bsearch crypt lfind lsearch qsort rand srand
crypt(将密码或数据编码) 相关函数 getpass 表头文件 #define _XOPEN_SOURCE #include<unistd.h> 定义函数 char * crypt ( ...
- 【BZOJ】【3262】陌上花开
树套树 orz zyf 这题的思路……算是让我了解到了树套树的一种用途吧 三维...第一维排序,第二维树状数组,第三维treap 具体实现就是每个树状数组的节点保存一颗treap,然后就可以查询了. ...
- Python并发编程-Redis
Redis 简介 Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. Remote Dictionary Server(Redis)是一个基于 key-value ...
- vue-router登录校验后跳转到之前指定页面如何实现
两个需求:1.用户点击购买需要下单,并跳转到订单页面,但是如果用户没有登录的话,中间有登录验证,会拦截:2.点击购买的时候,登录校验成功了,跳转到订单页面时,订单已创建,去付款即可.3.处理拦截至登录 ...
- Android之PowerManager&BatteryManager
PowerManager是Android平台中用于管理控制设备电源状态.重启.休眠状态.唤醒等,使用该API会影响到电池的待机时间,所以无非必要,一般不要使用. 在PowerManager中有几个比较 ...
- Linux下C与Mysql的混合编程
1 概述 MySQL 是一个关系型数据库管理系统.由瑞典MySQL AB公司开发,眼下属于Oracle公司.MySQL是最流行的关系型数据库管理系统. 支持AIX.FreeBSD.HP-UX.Linu ...
- Qt之设置窗口背景
以前遇到的很多小知识,从今天开始都一点一点记录下来... 窗口背景无非两种:背景色.背景图片.Qt中窗口背景如何设置?下面介绍三种方法: 一. QPalette设置背景 二.实现paintEv ...