Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class whiteSheet {
- static int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
- public static int f(double x,double y)//checks if (x,y) lies inside any one of the black sheets
- { if(x>=x3 && y>=y3 && x<=x4 && y<=y4)
- return 1;
- if(x>=x5 && y>=y5 && x<=x6 && y<=y6)
- return 1;
- return 0;
- }
- public static void main(String[] args) throws IOException {
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- String s[]=br.readLine().split(" ");//start of reading input
- x1=Integer.parseInt(s[0]);
- y1=Integer.parseInt(s[1]);
- x2=Integer.parseInt(s[2]);
- y2=Integer.parseInt(s[3]);
- String st[]=br.readLine().split(" ");
- x3=Integer.parseInt(st[0]);
- y3=Integer.parseInt(st[1]);
- x4=Integer.parseInt(st[2]);
- y4=Integer.parseInt(st[3]);
- String str[]=br.readLine().split(" ");
- x5=Integer.parseInt(str[0]);
- y5=Integer.parseInt(str[1]);
- x6=Integer.parseInt(str[2]);
- y6=Integer.parseInt(str[3]);
- boolean fl=false;
- for(double i=x1;i<=x2;i+=0.5)//as all coordinates are integers smallest gap possible is 1 (because 0 gap means no gap).To check
- inside that gap also, i is incremented by 0.5
- { if(f(i,y1)==0)
- { fl=true;
- break;
- }
- if(f(i,y2)==0)
- { fl=true;
- break;
- }
- }//this for loop is to check the points on horizontal boundaries of white sheet
- for(double i=y1;i<=y2;i+=0.5)
- { if(f(x1,i)==0)
- { fl=true;
- break;
- }
- if(f(x2,i)==0)
- { fl=true;
- break;
- }
- }//this for loop is to check the points on vertical boundaries of white sheet
- if(fl==true)
- System.out.print("YES");
- else
- System.out.print("NO");
- }
- }
Add Comment
Please, Sign In to add comment