POJ 2585Window Pains
来源:互联网 发布:mac口红一盒 编辑:程序博客网 时间:2024/05/18 01:24
Window Pains
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1994 Accepted: 1007
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:
11..11...........22..22...........33..33............44..44...........55..55...........66..66............77..77...........88..88...........99..99
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:122?122?????????If window 4 were then brought to the foreground:122?442?44??????. . . and so on . . . 11..11...........22..22...........33..33............44..44...........55..55...........66..66............77..77...........88..88...........99..99
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:
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.
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
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
THESE WINDOWS ARE CLEAN
Otherwise, the output will be a single line with the statement:
THESE WINDOWS ARE BROKEN
Sample Input
START1 2 3 34 5 6 67 8 9 97 8 9 9ENDSTART1 1 3 34 1 3 37 7 9 97 7 9 9ENDENDOFINPUT
Sample Output
THESE WINDOWS ARE CLEANTHESE WINDOWS ARE BROKEN
Source
South Central USA 2003
题比较难读,然后窗口处理这块很有意思,感觉没有接触过很难想到方法。
窗口具体怎么处理可以看代码里的注释。主要就是把所有窗口走一遍,和他位置不同的表示被覆盖了。题意有时间了补一下吧……现在不太想翻译_(:з」∠)_
#include<stdio.h>#include<string.h>#include<algorithm>#include<queue>using namespace std;int map[15][15],G[15],screen[5][5];int dis[4][2]={{0,0},{1,0},{0,1},{1,1}};//窗口的范围 int local[10][2]={{-1,-1},{0,0},{0,1},{0,2},{1,0},{1,1},{1,2},{2,0},{2,1},{2,2}};//每个窗口右上角点的坐标 int top(){int i,j,tmp,flag;for(i=1;i<=9;i++){flag=0;for(j=1;j<=9;j++)if(G[j]==0){flag=1;tmp=j;break;}if(!flag) return 0;G[tmp]=-1;for(j=1;j<=9;j++)if(map[tmp][j])G[j]--;}return 1;}int main(){char ch[15];int i,j;while(scanf("%s",ch)&&strcmp(ch,"ENDOFINPUT")!=0){memset(map,0,sizeof(map));memset(G,0,sizeof(G));for(i=0;i<4;i++)for(j=0;j<4;j++)scanf("%d",&screen[i][j]);scanf("%s",ch);for(i=1;i<=9;i++){for(j=0;j<4;j++){int x=local[i][0]+dis[j][0];//i窗口的坐标 int y=local[i][1]+dis[j][1];int z=screen[x][y];//这个坐标在屏幕里的实际窗口 if(z!=i&&!map[i][z])//不同说明覆盖 {map[i][z]=1;G[z]++;}}}if(top())printf("THESE WINDOWS ARE CLEAN\n"); else printf("THESE WINDOWS ARE BROKEN\n");}return 0;}
0 0
- poj 2585 Window Pains
- POJ-2585 Window Pains
- poj 2585 Window Pains
- POJ-2585 Window Pains
- POJ 2585Window Pains
- 【POJ】[2585]Window Pains
- Window Pains POJ 2585
- POJ 2585 Window Pains【拓扑】
- POJ 2585 Window Pains 拓扑排序
- POJ 2585 | ZOJ 2193 Window Pains
- poj 2585 Window Pains (有向环)
- POJ 2585 Window Pains (拓扑排序)
- POJ:2585 Window Pains(拓扑排序)
- poj 2585 Window Pains zoj 2193
- [POJ 2585] Window Pains (拓扑排序)
- POJ 2585 Window Pains(拓扑排序判定)
- poj 2585 Window Pains 拓扑排序
- POJ 2585 zoj 2193 Window Pains
- JS代码优化一:谷歌浏览器的timeline工具的使用
- jQuery对象和DOM对象相互装换
- 09.Apache 2.4 基于端口配置多个Diango项目
- hdu5783(2016多校第五场,dp)
- linphone-PresenceServiceImpl文件对应的JNI层文件分析
- POJ 2585Window Pains
- 【笔试面试】第三波
- Memcached
- Java基础之-IO中的字节流
- 随机数
- 关于 tomcat 与X-Frame-Options
- linphone-ErrorInfoImpl文件对应的JNI层文件分析
- shell编程入门开始:
- HDOJ 2094 产生冠军