首页 技术 正文
技术 2022年11月21日
0 收藏 683 点赞 2,676 浏览 4176 个字

Window Pains

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 2027   Accepted: 1025

Description

Boudreaux likes to multitask, especially when it comes to using his computer. Never satisfied with just running one application at a time, he usually runs nine applications, each in its own window. Due to limited screen real estate, he overlaps these windows and brings whatever window he currently needs to work with to the foreground. If his screen were a 4 x 4 grid of squares, each of Boudreaux’s windows would be represented by the following 2 x 2 windows:

1 1 . .
1 1 . .
. . . .
. . . .
. 2 2 .
. 2 2 .
. . . .
. . . .
. . 3 3
. . 3 3
. . . .
. . . .
. . . .
4 4 . .
4 4 . .
. . . .
. . . .
. 5 5 .
. 5 5 .
. . . .
. . . .
. . 6 6
. . 6 6
. . . .
. . . .
. . . .
7 7 . .
7 7 . .
. . . .
. . . .
. 8 8 .
. 8 8 .
. . . .
. . . .
. . 9 9
. . 9 9

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:

1 2 2 ?
1 2 2 ?
? ? ? ?
? ? ? ?
If window 4 were then brought to the foreground:
1 2 2 ?
4 4 2 ?
4 4 ? ?
? ? ? ?

. . . 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

Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets.

A single data set has 3 components: 

  1. Start line – A single line: 
    START
  2. 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.
  3. 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

For each data set, there will be exactly one line of output. If there exists a sequence of bringing windows to the foreground that would result in the graphical representation of the windows on Boudreaux’s screen, the output will be a single line with the statement:

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

South Central USA 2003——————————————————我是分割线——————————————————拓扑排序,绝世好题。前5分钟只想出来暴搜方法后来想到可以记录每个方格能被哪些窗口盖住转化成图论问题,拓扑排序求环有环就是死机,否则就是好的。真是的,如果不是事先知道这题是拓扑排序,我就只会写一发搜索剪枝去骗分了…….读入写错了,调了半个钟头。

 /*
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

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,580
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918