Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main(){
- int x[5],y[5];
- while(scanf("%d %d %d %d %d %d %d %d",&x[1],&y[1],&x[2],&y[2],&x[3],&y[3],&x[4],&y[4])!= EOF){
- bool bx[1001],by[1001];
- for(int i = 0;i<1001;i++){
- bx[i] = false;
- by[i] = false;
- }
- for(int i = x[1];i<x[2]+1;i++)bx[i] = true;
- for(int i = y[1];i<y[2]+1;i++)by[i] = true;
- int countx = -1,county = -1;
- for(int i = x[3];i<x[4]+1;i++)if(bx[i] == true)countx++;
- for(int i = y[3];i<y[4]+1;i++)if(by[i] == true)county++;
- if(countx > 0 && county > 0)printf("overlap=%d\n", countx*county);
- else if((countx == 0 && county > 0)||(countx > 0 && county == 0))
- if(!countx)printf("touch=%d\n",county);
- else printf("touch=%d\n", countx);
- else if(!countx && !county){
- if(x[1] == x[3] || x[1] == x[4])printf("x=%d\n",x[1]);
- else if(x[2] == x[3] || x[2] == x[4])printf("x=%d\n",x[2]);
- if(y[1] == y[3] || y[1] == y[4])printf("y=%d\n", y[1]);
- else if(y[2] == y[3] || y[2] == y[4])printf("y=%d\n", y[2]);
- }
- else if(countx == -1 || county == -1){
- int minx = 9999, miny = 9999;
- for(int i = 1;i<3;i++)
- for(int j = 3;j<5;j++){
- if(abs(x[i]-x[j])<minx)minx = abs(x[i]-x[j]);
- if(abs(y[i]-y[j])<miny)miny = abs(y[i]-y[j]);
- }
- if(countx != -1)printf("dis=sqrt(%d)\n",miny*miny);
- else if(county != -1)printf("dis=sqrt(%d)\n",minx*minx);
- else printf("dis=sqrt(%d)\n", minx*minx+miny*miny);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement