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 ...
随机推荐
- javascript倒计时调转页面
<html><head><meta http-equiv="Content-Type" content="text/html; charse ...
- 静默获取微信用户openid如此简单,只需要一句话
页面A getopenid.php <?php /** * Created by PhpStorm. * User: sunjianyin * Date: 2017/10/7 * Time: 下 ...
- 一个简易内存池(C++)
做这个内存池主要是为了完成一道面试题,题目在代码中. 代码 #include <iostream> #include<string> #include <list> ...
- Pick apples(大范围贪心,小范围完全背包)
Pick apples Time Limit: 1000MS Memory Limit: 165536KB Submit Statistic Discuss Problem Description O ...
- Android 开发笔记___switch__开关
default switch <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ...
- input 密码框调出手机的数字键盘
对于某些密码,想要在手机上调出数字键盘,同时要隐藏文字.可结合type=tel和 text-security属性达到目的. input{ -webkit-text-security:disc; tex ...
- J1001.Java原生桌面及Web开发浅谈
自从Java问世以来,在服务端开发方面取得了巨大的发展.但是在桌面/Web开发方面,一直没有得到大的发展.从最初的AWT,到Swing,再到JavaFX,Java从来没有在桌面/Web解决方案中取得重 ...
- 双11Java程序员书单推荐
Java <Java核心技术卷I> <Java核心技术卷II> <Java编程思想> <Java并发编程实战> <Effective Java&g ...
- CSS实现父元素半透明,子元素不透明
CSS实现父元素半透明,子元素不透明. 很久以来大家都习惯使用opacity:0.5在新式浏览器里实现半透明,而对IE较旧的版本使用filter:Alpha(opacity=0.5)的滤镜来实现半透明 ...
- 用python模拟登录(解析cookie + 解析html + 表单提交 + 验证码识别 + excel读写 + 发送邮件)
老婆大人每个月都要上一个网站上去查数据,然后做报表. 为了减轻老婆大人的工作压力,所以我决定做个小程序,减轻我老婆的工作量. 准备工作 1.tesseract-ocr 这个工具用来识别验证码,非常好用 ...