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 ...
随机推荐
- 设计模式之责任链模式——Java语言描述
责任链模式为请求创建了一个接受者对象的链.这种模式给予请求的类型,对请求的发送者和接受者进行解耦.这种类型的设计模式属于行为模式.在这种模式下,通常每个接收者都包含对另一个接收者的引用.如果一个对象不 ...
- Bootstarp的安装以及简单的使用方法(pycharm中)
一.安装 首先打开Bootstarp的官网:https://v3.bootcss.com 下载完成后,解压压缩包,把解压后的文件导入pycham中 在HTML页面中的style中导入bootstrap ...
- Android之Retrofit详解(转载)
说明:该文章转载于https://www.jianshu.com/p/a3e162261ab6 前言 在Andrroid开发中,网络请求十分常用 而在Android网络请求库中,Retrofit是当下 ...
- Android 上传图片到服务器二--------调用相机7.0以上权限问题
[目录] (一)上传图片到服务器一 ---------------------------------Android代码 (二)上传图片到服务器二--------------------------- ...
- 如何用RSS订阅?
本文由云+社区发表 摘要:我们常常会有订阅别人文章的需求,有更新的时候希望能有提醒的功能,RSS就是这样一个订阅的方式.很多网站上看到RSS的入口,点进去以后总是显示一堆的XML代码,我们来看看怎么使 ...
- ReactNative之参照具体示例来看RN中的FlexBox布局
今天是重阳节,祝大家节日快乐,今天继续更新RN相关的博客.上篇博客<ReactNative之从HelloWorld中看环境搭建.组件封装.Props及State>中我们通过一个HelloW ...
- GitHub开源:SQLite 增强组件 Sheng.SQLite.Plus
Github:https://github.com/iccb1013/Sheng.SQLite.Plus Sheng.SQLite.Plus 是一个对直接使用 ADO.NET 方式操作 SQLite ...
- 为什么不要使用 async void?
问题 在使用 Abp 框架的后台作业时,当后台作业抛出异常,会导致整个程序崩溃.在 Abp 框架的底层执行后台作业的时候,有 try/catch 语句块用来捕获后台任务执行时的异常,但是在这里没有生效 ...
- Mybatis之旅第二篇-Mapper动态代理方式
一.引言 通过上一篇mybatis的入门学习,我们已经会使用mybatis实现简单的增删改查,但是我们也发现了用原始Dao开发的一些问题: Dao方法体存在重复代码:通过SqlSessionFacto ...
- 《深入理解Java虚拟机》-----第4章 虚拟机性能监控与故障处理工具
理论总是作为指导实践的工具,能把这些知识应用到实际工作中才是 我们的最终目的. 给一个系统定位问题的时候,知识.经验是关键基础,数据是依据,工具是运用知识处理数据的手段.这里说的数据包括:运行日志.异 ...