NOIP201105 Floor Carpet

Source: Internet
Author: User

NOIP201105 Floor Carpet
Difficulty level: A; run time limit: 1000ms; operating space limit: 51200KB; code length limit: 2000000B
Question Description
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
Enter a total n+2 line. The first line, an integer n, 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 integer a,b,g,k, separated by a space between each two integers, representing the coordinates (a, b) of the lower-left corner of the carpet and the length of the carpet in the X-and y-axis directions. 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
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.
Input example
3
1 0 2 3
0 2 3 3
2 1 3 3
2 2
Output example
3
Other Notes
Tips:

Data range:

30% n<=2

50% 0<=a,b,g,k<=100

100% 0<=n<=10000, 0<=a,b,g,k<=100000
1#include <iostream>2 3 using namespacestd;4 intN;5 inta[10101],b[10101],x[10101],y[10101];6 intMain ()7 {8scanf"%d",&n);9      for(intI=1; i<=n;i++) scanf ("%d%d%d%d",&a[i],&b[i],&x[i],&y[i]);Ten     intXx,yy; Onescanf"%d%d",&xx,&yy); A      for(inti=n;i>=1; i--)//because the carpet is from small to large shop, so in turn find will be faster to find the top -     { -         if(a[i]<=xx && a[i]+x[i]>=xx && b[i]<=yy && b[i]+y[i]>=yy)//The current carpet contains this point the         { -printf"%d", i); -             return 0; -         } +     } -printf"-1"); +     //System ("pause"); A     return 0; at}
NOIP201105 Floor Carpet

NOIP201105 Floor 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.