poj 2585 Window Pains 解题报告
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2027 | Accepted: 1025 |
Description
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
When Boudreaux brings a window to the foreground, all of its squares come to the top, overlapping any squares it shares with other windows. For example, if window 1and then window 2 were brought to the foreground, the resulting representation would be:
|
If window 4 were then brought to the foreground: |
|
. . . and so on . . .
Unfortunately, Boudreaux's computer is very unreliable and crashes often. He could easily tell if a crash occurred by looking at the windows and seeing a graphical representation that should not occur if windows were being brought to the foreground correctly. And this is where you come in . . .
Input
A single data set has 3 components:
- Start line - A single line:
START - Screen Shot - Four lines that represent the current graphical representation of the windows on Boudreaux's screen. Each position in this 4 x 4 matrix will represent the current piece of window showing in each square. To make input easier, the list of numbers on each line will be delimited by a single space.
- End line - A single line:
END
After the last data set, there will be a single line:
ENDOFINPUT
Note that each piece of visible window will appear only in screen areas where the window could appear when brought to the front. For instance, a 1 can only appear in the top left quadrant.
Output
THESE WINDOWS ARE CLEAN
Otherwise, the output will be a single line with the statement:
THESE WINDOWS ARE BROKEN
Sample Input
START
1 2 3 3
4 5 6 6
7 8 9 9
7 8 9 9
END
START
1 1 3 3
4 1 3 3
7 7 9 9
7 7 9 9
END
ENDOFINPUT
Sample Output
THESE WINDOWS ARE CLEAN
THESE WINDOWS ARE BROKEN
Source
/*
Problem:poj 2585
OJ: POJ
User: S.B.S.
Time: 0 ms
Memory: 700 kb
Length: 1991 b
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<iomanip>
#include<cassert>
#include<climits>
#include<vector>
#include<list>
#include<map>
#define maxn 10001
#define F(i,j,k) for(int i=j;i<k;i++)
#define M(a,b) memset(a,b,sizeof(a))
#define FF(i,j,k) for(int i=j;i>=k;i--)
#define inf 0x7fffffff
#define maxm 2016
#define mod 1000000007
//#define LOCAL
using namespace std;
int read(){
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int n,m;
int sc[][];
string cr[][];
bool vis[];
int in[];
bool g[][];
int t;
string s;
inline void init()
{
F(i,,)F(j,,) cr[i][j].erase();
F(k,,){
int i=(k-)/;
int j=(k-)%;
cr[i][j]+=char(k+'');
cr[i][j+]+=char(k+'');
cr[i+][j]+=char(k+'');
cr[i+][j+]+=char(k+'');
}
}
inline void input()
{
int i,j;
M(vis,);M(in,);M(g,);
t=;
int k;
F(i,,)F(j,,){
cin>>k;
sc[i][j]=k;
if(!vis[k]) t++;
vis[k]=true;
}
}
inline void build()
{
int a,b;
F(i,,)F(j,,)F(k,,cr[i][j].length())
{
if((!g[sc[i][j]][cr[i][j][k]-''])&&(sc[i][j]!=cr[i][j][k]-''))
{
g[sc[i][j]][cr[i][j][k]-'']=true;
in[cr[i][j][k]-'']++;
}
}
}
inline bool ok()
{
int i,j,k;
F(k,,t){
i=;
while(!vis[i]||(i<=&&in[i]>)) i++;
if(i>) return false;
vis[i]=false;
F(j,,){
if(vis[j]&&g[i][j]) in[j]--;
}
}
return true;
}
int main()
{
std::ios::sync_with_stdio(false);//cout<<setiosflags(ios::fixed)<<setprecision(1)<<y;
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif
init();
while(cin>>s)
{
if(s=="ENDOFINPUT") break;
input();
build();
if(ok()) cout<<"THESE WINDOWS ARE CLEAN"<<endl;
else cout<<"THESE WINDOWS ARE BROKEN"<<endl;
cin>>s;
}
return ;
}
poj 2585
poj 2585 Window Pains 解题报告的更多相关文章
- POJ 2585.Window Pains 拓扑排序
Window Pains Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1888 Accepted: 944 Descr ...
- poj 2585 Window Pains 暴力枚举排列
题意: 在4*4的格子中有9个窗体,窗体会覆盖它之下的窗体,问是否存在一个窗体放置的顺序使得最后的结果与输入同样. 分析: 在数据规模较小且不须要剪枝的情况下能够暴力(思路清晰代码简单),暴力一般分为 ...
- POJ 2585 Window Pains 题解
链接:http://poj.org/problem?id=2585 题意: 某个人有一个屏幕大小为4*4的电脑,他很喜欢打开窗口,他肯定打开9个窗口,每个窗口大小2*2.并且每个窗口肯定在固定的位置上 ...
- zoj 2193 poj 2585 Window Pains
拓扑排序. 深刻体会:ACM比赛的精髓之处不在于学了某个算法或数据结构,而在于知道这个知识点但不知道这个问题可以用这个知识去解决!一看题目,根本想不到是拓扑排序.T_T...... #include& ...
- [POJ 2585] Window Pains 拓朴排序
题意:你现在有9个2*2的窗口在4*4的屏幕上面,由于这9这小窗口叠放顺序不固定,所以在4*4屏幕上有些窗口只会露出来一部分. 如果电脑坏了的话,那么那个屏幕上的各小窗口叠放会出现错误.你的任务就是判 ...
- 【原创】leetCodeOj --- Sliding Window Maximum 解题报告
天,这题我已经没有底气高呼“水”了... 题目的地址: https://leetcode.com/problems/sliding-window-maximum/ 题目内容: Given an arr ...
- Tarjan算法求解桥和边双连通分量(附POJ 3352 Road Construction解题报告)
http://blog.csdn.net/geniusluzh/article/details/6619575 在说Tarjan算法解决桥和边双连通分量问题之前我们先来回顾一下Tarjan算法是如何 ...
- POJ 3126 Prime Path 解题报告(BFS & 双向BFS)
题目大意:给定一个4位素数,一个目标4位素数.每次变换一位,保证变换后依然是素数,求变换到目标素数的最小步数. 解题报告:直接用最短路. 枚举1000-10000所有素数,如果素数A交换一位可以得到素 ...
- 【原创】poj ----- 2376 Cleaning Shifts 解题报告
题目地址: http://poj.org/problem?id=2376 题目内容: Cleaning Shifts Time Limit: 1000MS Memory Limit: 65536K ...
随机推荐
- 【POJ】1740.A New Stone Game
题解 想去学习一下博弈论的SG函数 不过貌似这道题就是猜结论并且证明 题意是,随便选择一堆石子,扔掉至少一个,然后从扔石子的这堆里选择任意多(可以不选)放到其他任意多的未选择完的石堆里 一堆石子,先手 ...
- Git配置用户名密码
配置Git 在Linux下和windows下配置Git的方法差不多,只是在Linux下,可以在命令行里直接使用git config进行配置, 而在windows下则要先打开“Git Bash”,进入m ...
- iOS Sprite Kit教程之场景的设置
iOS Sprite Kit教程之场景的设置 Sprite Kit中设置场景 在图2.8所示的效果中,可以看到新增的场景是没有任何内容的,本节将讲解对场景的三个设置,即颜色的设置.显示模式的设置以及测 ...
- python opencv3 摄像头人脸检测
git:https://github.com/linyi0604/Computer-Vision # coding:utf8 import cv2 def detect(): # 创建人脸检测的对象 ...
- C# 集合类-使用
关联性集合类 关联性集合类即我们常说的键值对集合,允许我们通过Key来访问和维护集合. 我们来看一下 .net 为我们提供了哪些泛型的关联性集合类: Dictionary<TKey,TValu ...
- luoguP4783 [模板]矩阵求逆 线性代数
求\(n^2\)的矩阵的逆 翻了翻题解,看到了初等矩阵这个东西,突然想起来在看线代的时候看到过.... 然后又温习了一遍线性代数的知识 不妨设\(PA = E\),其中\(P\)是一堆初等矩阵的积(必 ...
- 【set】【可持久化Trie】The 16th UESTC Programming Contest Preliminary K - Will the circle be broken
题意:You are given an array A of N non-negative integers and an integer M. Find the number of pair(i,j ...
- ASP.NET 构建高性能网站 第5篇
利用分析工具分析加载页面信息 站点的优化说到底还是站点每一个页面的优化,即使得站点的页面更快的呈现在用户的眼前.所以在此之前,我们首先来看看一个web页面的组成部分: 1. Html文件:在ASP.N ...
- redis-py说明文件(转)
转自:http://blog.sina.com.cn/s/blog_6262a50e0101574h.html 原文:https://github.com/andymccurdy/redis-py r ...
- [Windows核心编程]32bit程序在64bit操作系统下处理重定向细节[1]
这段时间,都在做Ring3层的普通32bit程序兼容64bit操作系统的代码修改,在此记录修改和学习心德.编程领域太广, 任何人经历有限,本人不是专家,所以我一贯原则是: 用到的时候,才去研究,在去记 ...