• the meaning of problems
Give you three rectangles are numbered 1, 2;
Determining whether the rectangle is a rectangle, and a rectangular 2 3 completely covered;
If not completely cover, output "YES", on the contrary, the output "NO";
•answer
I used to do a scan line;
First, the data structure is defined as follows:
1 struct Data 2 { 3 int x; 4 int y1,y2; 5 int f; 6 int id; 7 bool operator < (const Data& obj)const 8 { 9 return x < obj.x; 10 } 11 }line[10],white[2];To scan a vertical side;
These three rectangular left and right side respectively stored in said data structure;
1 and save approximately rectangular sides;
. 1 int NUM = 0 ; 2 for ( int I = . 1 ; I <= . 3 ; ++ I) . 3 { . 4 int X1, Y1; . 5 int X2, Y2; . 6 Scanf ( " % D%% D D D% " , & X1, & Y1, & X2, & Y2); . 7 . 8 IF (I == . 1 ) . 9 { 10 White [ 0 ] = {X1, Y1, Y2, . 1 , I}; /// F =. 1 indicates that the edge is left of the current rectangle, f = -1 indicates that the edge is right of the current rectangle . 11 White [ . 1] = {X2, Y1, Y2, - 1 , I}; /// two vertical edges of a storage matrix 12 is } 13 is Line [NUM ++] = {X1, Y1, Y2, a , I}; / // save the vertical side of the matrix 14 Line [NUM ++] = {X2, Y1, Y2, - . 1 , I}; 15 }After a good edge information is stored, arranged in ascending order of x;
The next step is determining whether the rectangle is completely covered by 3 sides of a vertical rectangle;
However, only a vertical edge is determined whether it is not enough to completely cover, but also need to scan a horizontal edge;
The reason you can simulate what the following examples:
0 0 4 4 0 0 4 2 0 3 4 4In this case, we have the need to preserve the rectangle on the bottom, and scan it again again;
Only when vertical sides and horizontal sides of the rectangle 1 are completely covered 2,3 are rectangular, the rectangle can be described by a rectangle entirely covering the 2,3;
•Code
• Wa off sample
10 10 11 11 10 10 11 11 10 10 11 11This example illustrates a very clear statement determines the placement of the Code 49 to line 50 and how to determine the condition judgment;
There is a solution to a problem in the above examples clearly illustrates why to be scanned twice;