POJ 3923 HDU 2487 Ugly Windows 简单计算
Ugly Windows
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1670 Accepted Submission(s): 693
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?
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.
..........................
....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
AD
#include <iostream>
#include <vector>
using namespace std;
const int big=;
const int maxn=;
struct aaa {
int x,y;
};
vector<aaa> c;
int n,m;
char a[maxn][maxn];
void make() {
char ch;
int i,j,minx,maxx,miny,maxy;
aaa node;
bool f;
for(ch='A';ch<='Z';ch++) {
c.clear();
for(i=;i<=n;++i)
for(j=;j<=m;++j)
if(a[i][j]==ch) {
node.x=i;node.y=j;
c.push_back(node);
}
if(c.size()==) continue;
minx=big;miny=big;maxx=;maxy=;
for(i=;i<(int)c.size();++i) {
if(c[i].x<minx) minx=c[i].x;
if(c[i].y<miny) miny=c[i].y;
if(c[i].x>maxx) maxx=c[i].x;
if(c[i].y>maxy) maxy=c[i].y;
}
if(maxx<minx+) continue;
if(maxy<miny+) continue;
if((int)c.size()!=(maxx-minx+maxy-miny)*) continue;
f=true;
for(i=minx+;i<maxx;++i)
for(j=miny+;j<maxy;++j)
if(isupper(a[i][j])) f=false;
if(f) cout<<ch;
}
cout<<endl;
}
int main() {
int i,j;
while(true) {
cin>>n>>m;
if(n+m==) break;
for(i=;i<=n;++i)
for(j=;j<=m;++j)
cin>>a[i][j];
make();
}
return ;
}
POJ 3923 HDU 2487 Ugly Windows 简单计算的更多相关文章
- 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 ...
- HDU 2487 Ugly Windows
递归求解,代码不太好看,是2013年7月写的 代码: #include<stdio.h> #include<iostream> #include<string.h> ...
- HDU 2487 Ugly window
这是切的很痛苦的一道题,自己测试了很多样例却终究不过,中间也做了诸多修改,后来无奈去网上看题解,发现遗漏了一种情况,就是两个窗口可能边框都能看见,但是一个嵌套在另一里面,而我判定是不是 “top wi ...
- 【HDOJ】2487 Ugly Windows
暴力解. #include <cstdio> #include <cstring> #define MAXN 105 char map[MAXN][MAXN]; ]; int ...
- POJ 1177/HDU 1828 picture 线段树+离散化+扫描线 轮廓周长计算
求n个图矩形放下来,有的重合有些重合一部分有些没重合,求最后总的不规则图型的轮廓长度. 我的做法是对x进行一遍扫描线,再对y做一遍同样的扫描线,相加即可.因为最后的轮廓必定是由不重合的线段长度组成的, ...
- poj 1251 poj 1258 hdu 1863 poj 1287 poj 2421 hdu 1233 最小生成树模板题
poj 1251 && hdu 1301 Sample Input 9 //n 结点数A 2 B 12 I 25B 3 C 10 H 40 I 8C 2 D 18 G 55D 1 E ...
- POJ 2104&HDU 2665 Kth number(主席树入门+离散化)
K-th Number Time Limit: 20000MS Memory Limit: 65536K Total Submissions: 50247 Accepted: 17101 Ca ...
- POJ 3181 Dollar Dayz(全然背包+简单高精度加法)
POJ 3181 Dollar Dayz(全然背包+简单高精度加法) id=3181">http://poj.org/problem?id=3181 题意: 给你K种硬币,每种硬币各自 ...
- SDUT OJ 2616 简单计算
简单计算 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 某天,XX 给YY 出了一道题,题目是: 给出n 个十进制的数,找出这n ...
随机推荐
- SpringMVC 集成redis
一.下载导入jar 二.配置redis 1.创建redis.properties # Redis settings #redis.host=192.168.20.101 #redis.port= #r ...
- N厂水鬼烂大街?那来看ZF厂V4帝舵小红花
自从帝舵小红花推上市面之后,各大工厂都在推出新版本,但做得最成熟的还是ZF厂,帝舵这个品牌是非常低调的,很少有人关注,但是ZF厂在这款腕表也是下了不少功夫,曾经帝舵小红花和N厂水鬼并列为最顶级的表畅销 ...
- CSS基础:基础和语法
**CSS语法** CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明.选择器通常是您需要改变样式的 HTML 元素.```selector {declaration1; declarati ...
- Windows环境下多线程编程原理与应用读书笔记(2)————面向对象技术
面向对象技术是学C++需要重点掌握的知识,因为我觉得自己的基础还是比较可以,这一章节的内容就只是粗略的读了一遍,在此就不做过多的笔记.
- 暑假练习赛 006 B Bear and Prime 100
Bear and Prime 100Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:262144KB ...
- 【G彩娱乐网】作为一名程序员,我应该如何选购一台电脑?
G彩娱乐网说到程序员专用电脑,那肯定是苹果电脑.优点有很多,比如白平衡特别准.酷炫的黑科技.特别方便的软件等显而易见的优势:也有能够增加提案通过率.专注工作提高工作效率这样的玄学buff. 但是!并不 ...
- [DeeplearningAI笔记]ML strategy_2_4端到端学习
机器学习策略-端到端学习 End-to-end deeplearning 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2.9 什么是端到端学习-What is End-to-end dee ...
- linux系统下解决getch()输入数值不回显示
在linux系统下开发C 程序却会遇到系统不支持conio.h头文件,无法使用getch()不回显函数.下面就演示如何构建函数实现数值输入不回显. #include <stdio.h> # ...
- Datatable转换为Json
/// <summary> /// Datatable转换为Json /// </summary> /// <param name="table"&g ...
- MVC 页面静态化
最近工作需要,实现页面静态化,以前在ASP时代,都是FSO自己手动生成的. 新时代,MVC了,当然也要新技术,网上一搜,找到一种解决方案,是基于MVC3的,实现原理是通过mvc提供的过滤器扩展点实现页 ...