cf 1216c

https://codeforc.es/problemset/problem/1216/C

Determine whether a rectangle is completely covered by the other two rectangles, this is my problem with discrete way to do. 

 1 #include<bits/stdc++.h>
 2 using namespace std;  
 3 int x[7],y[7],tx[7],ty[7];         
 4 int inner(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){ 
 5     return x1<=x3 && x4<=x2  && y1<=y3 &&  y4<=y2;   
 6 }
 7 int main(){
 8     for(int i=1;i<=6;i++)  
 9         scanf("%d%d",&x[i],&y[i]); 
10     for(int i=1;i<=6;i++)  
11         tx[i]=x[i],ty[i]=y[i];  
12     sort(tx+1,tx+7);     
13     sort(ty+1,ty+7);  
14     int m1=unique(tx+1,tx+7)-tx-1;  
15     int m2=unique(ty+1,ty+7)-ty-1;       
16     int s1,s2,s3,s4;  
17     for(int i=1;i<=m1;i++){
18         if(tx[i]==x[1]) s1=i;  
19         if(tx[i]==x[2]) s2=i;  
20     }
21     for(int i=1;i<=m2;i++){
22         if(ty[i]==y[1]) s3=i;  
23         if(ty[i]==y[2]) s4=i;  
24     }  
25     int check=0;   
26     for(int i=s1;i<s2;i++){
27         for(int j=s3;j<s4;j++){
28             if(!inner(x[3],y[3],x[4],y[4],tx[i],ty[j],tx[i+1],ty[j+1]) && !inner(x[5],y[5],x[6],y[6],tx[i],ty[j],tx[i+1],ty[j+1]))
29                 check=1;             
30         }
31     }
32     puts(check? "YES":"NO");  
33     return 0;  
34 }
View Code

 

Guess you like

Origin www.cnblogs.com/ZJXXCN/p/11595033.html