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 ;
}
1、因为漏写了那个break纠结了蛮久的,所以以后碰到循环都稍微想一想什么时候该停下来
2、因为忘记初始化win数组也纠结了一会,所以以后碰到数组都要记得初始化
3、因为窗口输入顺序是back to front,注意逆序寻找窗口
 
方法二:
 #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的更多相关文章

  1. ZOJ 2969 Easy Task

    E - Easy Task Description Calculating the derivation of a polynomial is an easy task. Given a functi ...

  2. 微软BI 之SSIS 系列 - 使用 Script Task 访问非 Windows 验证下的 SMTP 服务器发送邮件

    原文:微软BI 之SSIS 系列 - 使用 Script Task 访问非 Windows 验证下的 SMTP 服务器发送邮件 开篇介绍 大多数情况下我们的 SSIS 包都会配置在 SQL Agent ...

  3. NetBeans GUI tests on Jenkins + Windows (转)

    from http://forgetfulprogrammer.wordpress.com/tag/interact-with-desktop/ Running NetBeans applicatio ...

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

  5. windows提权基础大全

    Not many people talk about serious Windows privilege escalation which is a shame. I think the reason ...

  6. windows快捷命令修炼

    Description Windows Key combination Open/Close the Start Menu Windows key Open the Action center. Wi ...

  7. Linux常见问题及解决方案

    问题一: 删除Linux 的烦恼(没出现系统选择菜单只出现"grub": 问题描述: 安装了Linux.WinXP双系统,采用Grub引导系统.在XP下通过格式化磁盘(非法操作)删 ...

  8. word20161225

    Waiting for Call / 等待呼叫 wallpaper / 墙纸 WAN, wide area network / 广域网 warning level / 警告级别 Web folder ...

  9. (C#) 调用执行批处理文件

    Task:  在Windows的Service里面定时的调用执行一个批处理文件. private ApplicationOutput RunCommandOnPC(string executableP ...

随机推荐

  1. Canvas引入跨域的图片导致toDataURL()报错的问题的解决

    本文介绍了Canvas引入跨域的图片导致toDataURL()报错的问题的解决,分享给大家,具体如下: [场景] 用户打开网页,则请求腾讯COS(图片服务器)上的图片js代码.使用canvas绘图. ...

  2. Windows Server 2016-Hyper-V网络虚拟化概述

    在 Windows Server 2016 和虚拟机管理器中,Microsoft 提供的端到端网络虚拟化解决方案. 有构成了 Microsoft 的网络虚拟化解决方案的五个主要组件: Windows ...

  3. 远程连接身份验证错误,又找不到加密Oracle修正

    远程连接服务器出现了错误,错误信息为:远程连接身份验证错误,又找不到加密Oracle修正. 服务器系统:Windows Server2016 客户端系统:Windows10家庭版和专业版   出错原因 ...

  4. canvas百分比加载动画

    window.onload = function(){ var canvas = document.getElementById('canvas'), //获取canvas元素 context = c ...

  5. 【STM32H7教程】第3章 STM32H7整体把控

    完整教程下载地址:http://forum.armfly.com/forum.php?mod=viewthread&tid=86980 第3章   STM32H7整体把控 初学STM32H7一 ...

  6. LDAP概念和原理介绍

    LDAP概念和原理介绍 相信对于许多的朋友来说,可能听说过LDAP,但是实际中对LDAP的了解和具体的原理可能还比较模糊,今天就从“什么是LDAP”.“LDAP的主要产品”.“LDAP的基本模型”.“ ...

  7. 吴恩达机器学习笔记59-向量化:低秩矩阵分解与均值归一化(Vectorization: Low Rank Matrix Factorization & Mean Normalization)

    一.向量化:低秩矩阵分解 之前我们介绍了协同过滤算法,本节介绍该算法的向量化实现,以及说说有关该算法可以做的其他事情. 举例:1.当给出一件产品时,你能否找到与之相关的其它产品.2.一位用户最近看上一 ...

  8. 史上最全 40 道 Dubbo 面试题及答案,看完碾压面试官!

    想往高处走,怎么能不懂 Dubbo? Dubbo是国内最出名的分布式服务框架,也是 Java 程序员必备的必会的框架之一.Dubbo 更是中高级面试过程中经常会问的技术,无论你是否用过,你都必须熟悉. ...

  9. ubuntu上配置nginx实现反向代理

    反向代理 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客 ...

  10. 研究windows下SVN备份及还原恢复方案

    windows下SVN备份方案 备份策略 svn备份一般采用三种方式: 1)svnadmin dump  2)svnadmin hotcopy  3)svnsync.  注意,svn备份不宜采用普通的 ...