[To] lay the carpet

Source: Internet
Author: User

This blog post for the migration, written on November 3, 2014, does not represent my current views and views. Original address: http://blog.sina.com.cn/s/blog_6022c4720102ves6.html

Describe

In preparation for a unique award ceremony, the organizer paved rectangular carpets in a rectangular area of the venue (which can be seen as the first quadrant of a planar Cartesian coordinate system). A total of n carpets, numbered from 1 to N. The carpets are now laid out in the order of the numbers from small to large, and the carpets on the front floor are covered in the carpet. After the carpet is laid, the organizer wants to know the number of the top carpet that covers a point on the ground. Note: The points on the rectangular carpet boundary and the four vertices are also covered by carpets.

Input format

Enter a total n+2 line.

The first line, an integer n (0 <= N <= 10,000), indicates a total of n carpets.

In the next n rows, the I+1 line represents the information for the number I carpet, containing four positive integers a,b,g,k (0 <= A, B, G, K & lt;= 100,000), separated by a space between each two integers, representing the coordinates of the lower left corner of the carpet (A, b) and the length of the carpet in the x-axis and y-axis direction.

The n+2 line contains two positive integers x and y, representing the coordinates (x, y) of the point of the ground being asked.

Output format

Outputs a total of 1 lines, an integer representing the number of the carpet being asked for, or 1 if the carpet is not covered.

Sample Example

Sample input

3 1 0 2 3 0 2 3 3 2 1 3 3 2 2

Sample output

3

Ideas

Direct simulation of Thiophene!

Label

Simulation

Code

#include <cstdio>

int n,a[10005],b[10005],g[10005],k[10005],ans,x,y;

int main ()

{

int i;

scanf ("%d", &n);

for (i=1;i<=n;i++)

scanf ("%d%d%d", &a[i],&b[i],&g[i],&k[i]);

scanf ("%d%d", &x,&y);

for (i=1;i<=n;i++) if (X>=a[i] && x<=a[i]+g[i] && y>=b[i] && y<=b[i]+k[i]) ans=i;

if (ans==0) printf ("-1"); else printf ("%d", ans);

}

" 20141021 yards End Code "

[To] lay the carpet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.