ZOJ 2480 - Simplest Task in Windows
Time Limit: 2 Seconds Memory Limit: 65536 KB
A typical windows platform may have several windows on the desktop. A user's operation may be as simple as a single click of the mouse. In the implementation of such a windows platform, one of the simplest tasks would be deciding which window had been clicked.
Given a serial of windows, for each mouse click, decide which window had been clicked. Please notice that windows may overlap, and the window on top would receive the click rather than others. And, we consider a window to be clicked even if the mouse is just on its edge/corner. For the sake of simplicity, we assume that a window will not be activated to the top by any click.
Input
The first part of input is a serial of windows. First an integer N (1 <= N <= 10) is given, indicating the number of windows. Then N lines follow, each containing four integers, x1, y1, x2, y2, (x1 < x2, y1 < y2) the coordinates of the upper-left and lower-right corners of a window. The windows are given in back-to-front order. N=0 signals the end of input.
The second part of input is a serial of mouse clicks. First an integer M (1 <= M <= 50) is given, indicating the number of mouse clicks. Then M lines follow, each containing two integers, x and y, the coordinates of a mouse click.
Output
For each mouse click in the input, output a single line containing the index (starting from 0) of the window which receives the click. If there is no such window, output "-1" in a line instead.
Sample Input
1
0 0 5 5
3
4 1
5 1
6 1
0
Sample Output
0
0
-1
#include <iostream>
#include <cstdio>
using namespace std;
int win[][];
int main()
{ int N;
scanf("%d",&N);
while(N>){
for(int i=;i<N;i++)
for(int j=;j<;j++)
win[i][j]=-;
for(int i=;i<N;i++){
for(int j=;j<;j++){
int temp;
scanf("%d",&temp);
win[i][j]=temp;
}
}
int M;
bool flag=;
scanf("%d",&M);
for(int i=;i<M;i++){
flag=;
int cx,cy;
scanf("%d",&cx);
scanf("%d",&cy);
for(int j=N-;j>=;j--){
if(win[i][j]==-)
continue;
if(cx<=win[j][]&&cx>=win[j][]&&cy<=win[j][]&&cy>=win[j][]){
printf("%d\n",j);
flag=;
break;
}
}
if(!flag) printf("-1\n");
}
scanf("%d",&N);
}
return ;
}
#include <iostream>
#include <cstdio>
using namespace std;
int win[][];
int main()
{ int N;
scanf("%d",&N);
while(N>){
for(int i=;i<;i++){
for(int j=;j<;j++)
win[i][j]=-;
}
for(int i=;i<N;i++){
int l,d,r,u;
scanf("%d",&l);
scanf("%d",&d);
scanf("%d",&r);
scanf("%d",&u);
for(int j=l;j<=r;j++){
for(int k=d;k<=u;k++)
win[j][k]=i;
}
}
int M;
bool flag=;
scanf("%d",&M);
for(int i=;i<M;i++){
flag=;
int cx,cy;
scanf("%d",&cx);
scanf("%d",&cy);
if(win[cx][cy]!=-){
printf("%d\n",win[cx][cy]);
flag=;
}
if(!flag) printf("-1\n");
}
scanf("%d",&N);
}
return ;
}
根据别人的思路打的,这个思路也不错,用二维数组模拟一块屏幕,但是因为题目没有提及coordinate的xy取值范围,所以win的大小其实不好拿捏,但是这个107能AC
ZOJ 2480 - Simplest Task in Windows的更多相关文章
- ZOJ 2969 Easy Task
E - Easy Task Description Calculating the derivation of a polynomial is an easy task. Given a functi ...
- 微软BI 之SSIS 系列 - 使用 Script Task 访问非 Windows 验证下的 SMTP 服务器发送邮件
原文:微软BI 之SSIS 系列 - 使用 Script Task 访问非 Windows 验证下的 SMTP 服务器发送邮件 开篇介绍 大多数情况下我们的 SSIS 包都会配置在 SQL Agent ...
- NetBeans GUI tests on Jenkins + Windows (转)
from http://forgetfulprogrammer.wordpress.com/tag/interact-with-desktop/ Running NetBeans applicatio ...
- Windows Phone Silverlight 8.1 apps
The Windows Phone Silverlight 8.1 app model gives Windows Phone 8 developers access to some of the n ...
- windows提权基础大全
Not many people talk about serious Windows privilege escalation which is a shame. I think the reason ...
- windows快捷命令修炼
Description Windows Key combination Open/Close the Start Menu Windows key Open the Action center. Wi ...
- Linux常见问题及解决方案
问题一: 删除Linux 的烦恼(没出现系统选择菜单只出现"grub": 问题描述: 安装了Linux.WinXP双系统,采用Grub引导系统.在XP下通过格式化磁盘(非法操作)删 ...
- word20161225
Waiting for Call / 等待呼叫 wallpaper / 墙纸 WAN, wide area network / 广域网 warning level / 警告级别 Web folder ...
- (C#) 调用执行批处理文件
Task: 在Windows的Service里面定时的调用执行一个批处理文件. private ApplicationOutput RunCommandOnPC(string executableP ...
随机推荐
- C# 创建含多层分类标签的Excel图表
相较于数据,图表更能直观的体现数据的变化趋势.在数据表格中,同一数据值,可能同时代表不同的数据分类,表现在图表中则是一个数据体现在多个数据分类标签下.通常生成的图表一般默认只有一种分类标签,下面的方法 ...
- Vue.js 学习笔记 第4章 v-bind 及 class与style绑定
本篇目录: 4.1 了解v-bind指令 4.2 绑定class的几种方式 4.3 绑定内联样式 DOM元素经常会动态地绑定一些class类名或style样式,本章将介绍使用v-bind指令来绑定cl ...
- SuperMap iObject入门开发系列之五管线属性查询
本文是一位好友“托马斯”授权给我来发表的,介绍都是他的研究成果,在此,非常感谢. 管线属性查询功能针对单一管线图层进行特定的条件查询,然后将查询结果输出为列表,并添加点位闪烁功能,例如查询污水管线中, ...
- 理解Linux文档的默认安全机制、隐藏属性、特殊权限,妈妈在也不用担心你从删库到跑路!!!
写在前面 前面的章节 详解Linux文档属性.拥有者.群组.权限.差异,介绍了文档的基本权限,包括读写执行(r,w,x),还有文档若干的属性,包括是否为目录(d).文件(-).链接文件(l).拥有者. ...
- Redis集群架构
Redis集群概述 集群的核心意义只有一个:保证一个节点出现了问题之后,其他的节点可以继续提供服务使用. Redis基础部分讲解过主从配置:对于主从配置可以有两类:一主二从,层级关系.开发者一主二从是 ...
- 初试PySnooper
Pysooper是什么? 我们写代码会经常出现bug,有的人会使用断点调试器,但是设置这样的断点调试器是花时间的. 所以很多人会在可能出现错误的地方print打印来输出语句. Pysooper的作用有 ...
- IDEA设置热部署
1.点击File找到Settings打开. 1.2:找到Compiler将 Build project automatically 勾选 2.使用快捷键 Ctrl+Shift+A 搜索 re ...
- 每日分享!~ JavaScript(js数组如何在指定的位置插入一个元素)
这个想法是在一个面试题中看到的: 题目是这样的: // 一个数组,在指定的index 位置插入一个元素,返回一个新的数组,不改变原来的数组 <script> function inse ...
- 使用 Moq 测试.NET Core 应用 -- 其它
第一篇文章, 关于Mock的概念介绍: https://www.cnblogs.com/cgzl/p/9294431.html 第二篇文章, 关于方法Mock的介绍: https://www.cnbl ...
- redis的string类型!!!!
value的最大存储量为512m,可储存图像数据或json数据等 1.redis的增加操作 127.0.0.1:6379> set name China --返回ok,说明增加成功,若n ...