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 ...
随机推荐
- 入门者必看!SharePoint之CAML总结(实战)
分享人:广州华软 无名 一. 前言 在SharePoint中,不支持直接操作数据库,但开发过程中,避免不了查询数据,那么,在SharePoint中如何查询数据? 当然是使用CAML语法. 二. 目录 ...
- Python第二十六天 python装饰器
Python第二十六天 python装饰器 装饰器Python 2.4 开始提供了装饰器( decorator ),装饰器作为修改函数的一种便捷方式,为工程师编写程序提供了便利性和灵活性装饰器本质上就 ...
- Lnmp一键脚本
#!/bin/bash #================================================================ # Copyright (C) 2018 A ...
- php7连接mysql测试代码
php7连接mysql测试代码 <?php $mysqli = new mysqli("localhost", "root", "passwor ...
- 【转载】c++中堆、栈内存分配
一.内存划分 1.栈区(stack)— 由编译器自动分配释放 ,存放函数参数值,局部变量值等.其操作方式类似于数据结构中栈.2.堆区(heap) — 一般由程序员分配释放, 若程序员不释放,程序结束时 ...
- JVM内存结构/JVM运行时数据区,以及堆内存的划分
1.程序计数器: 程序计数器是线程私有的内存,JVM多线程是通过线程轮流切换并分配处理器执行时间的方式实现的,当线程切换后需要恢复到正确的执 行位置(处理器)时,就是通过程序计数器来实现的.此内存区域 ...
- Ocelot 资源汇总
前言 最近一两年.NET Core的关注度持续上升, 微服务及云原生应用开发上采用.NET Core也越来越多,Ocelot 作为.NET Core平台下一款开源的API 网关开发库越来越得到社区的认 ...
- Php如何返回json数据,前后端分离的基本解决方案
php返回json,xml,JSONP等格式的数据 返回json数据: header('Content-Type:application/json; charset=utf-8'); $arr = a ...
- Java面向对象概述及三大特征(封装,继承和多态)
一.面向对象思想 Java是面向对象的高级语言,对于Java语言来说,万事万物皆对象! 它的基本思想是使用类,对象,继承,封装,消息等基本概念进行程序设计.面向对象程序的最小单元是类,类代表了客观世界 ...
- Vuex,状态管理模式
对于 Vue 本人目前接触不深,只得浅层分析,Vue 是单向数据流, state,驱动应用的数据源: view,以声明方式将 state 映射到视图: actions,响应在 view 上的用户输入导 ...