AC Diary-Carpet Valley P1003 (water and water water)

Source: Internet
Author: User
Tags dashed line

Title 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/output format

Input format:

The input file name is carpet.in.

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 integers 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 format:

The output file name is Carpet.out.

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 and Output Sample input example # #:
31 0 2 30 2 3 32 1 3 32 2
Sample # # of output:
3
Input Sample #:
31 0 2 30 2 3 32 1 3 34 5
Output Example #:
-1
Description

"Sample Interpretation 1"

For example, the 1th carpet with a solid line, 2nd carpet with a dashed line, 3rd with a double solid lines, covering point (2,2) of the top of the carpet is 3rd carpet.

"Data Range"

For 30% of the data, there are n≤2;

For 50% data, 0≤a, B, G, k≤100;

For 100% of data, there are 0≤n≤10,000, 0≤a, B, G, k≤100,000.

The 1th question of noip2011 raising group Day1

Ideas:

Flood problem

Save the side first.

Then simulate

And then output the results

It's AC.

Come on, on the code:

#include <cstdio>using namespacestd;structNode {intX1,y1,x2,y2; Node () {} node (intY_,intX_intB_intA_) {X1=a_,y1=b_,x2=x1+x_,y2=y1+Y_; }        BOOLIf_in (intXinty) {if(X<=x2&&x>=x1&&y>=y1&&y<=y2)return true; Else return false; }};structNode carpet[100005];intnum_carpet,tmp_read_q,p_read_q,x_1,y_1,ans=-1;CharWord;intread_q () {tmp_read_q=0, p_read_q=1; word=GetChar ();  while(word<'0'|| Word>'9')    {        if(word=='-') p_read_q=-1; Word=GetChar (); }     while(word<='9'&& word>='0') {tmp_read_q=tmp_read_q*Ten+(int) (word-'0'); Word=GetChar (); }    returntmp_read_q;}intMain () {Num_carpet=read_q ();  for(intI=1; I<=num_carpet; i++) carpet[i]=node (read_q (), Read_q (), Read_q (), read_q ()); X_1=read_q (), y_1=read_q ();  for(intI=1; I<=num_carpet; i++)if(Carpet[i].if_in (x_1,y_1)) ans=i; printf ("%d\n", ans); return 0;}

AC Diary-Carpet Valley P1003 (water and water water)

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.