Title Description
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.
Enter a description
Input Description
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 description
Output Description
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 input
Sample Input
Example 1:
3
1 0 2 3
0 2 3 3
2 1 3 3
2 2
Example 2:
3
1 0 2 3
0 2 3 3
2 1 3 3
4 5
Sample output
Sample Output
Example 1:
3
Example 2:
-1
Data range and Tips
Data Size & Hint
Data range
For 30% of the data, there are n≤2;
For 50% data, 0≤a, B, G, k≤100;
For 100% of the data, there are 0≤n≤10,000,0≤a, B, G, k≤100,000.
The code is actually:
#include <cstdio>
int N,map[10010][4],a,b,ans;
int main () {
scanf ("%d", &n);
for (int i=1;i<=n;i++) scanf ("%d%d%d%d", &map[i][0],&map[i][1],&map[i][2],&map[i][3]);
scanf ("%d%d", &a,&b);
for (int i=1;i<=n;i++) if (map[i][0]<=a&&map[i][0]+map[i][2]>=a&&map[i][1]<=b& &MAP[I][1]+MAP[I][3]>=B) ans=i;
if (ans) printf ("%d\n", ans);
else printf (" -1\n");
return 0;
}
Water ~
Carpet laying 2011 NOIP National League Improvement Group