meghana180799

Untitled

Oct 8th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class whiteSheet {
  5. static int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
  6. public static int f(double x,double y)//checks if (x,y) lies inside any one of the black sheets
  7. { if(x>=x3 && y>=y3 && x<=x4 && y<=y4)
  8. return 1;
  9. if(x>=x5 && y>=y5 && x<=x6 && y<=y6)
  10. return 1;
  11. return 0;
  12. }
  13. public static void main(String[] args) throws IOException {
  14. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  15. String s[]=br.readLine().split(" ");//start of reading input
  16. x1=Integer.parseInt(s[0]);
  17. y1=Integer.parseInt(s[1]);
  18. x2=Integer.parseInt(s[2]);
  19. y2=Integer.parseInt(s[3]);
  20. String st[]=br.readLine().split(" ");
  21. x3=Integer.parseInt(st[0]);
  22. y3=Integer.parseInt(st[1]);
  23. x4=Integer.parseInt(st[2]);
  24. y4=Integer.parseInt(st[3]);
  25. String str[]=br.readLine().split(" ");
  26. x5=Integer.parseInt(str[0]);
  27. y5=Integer.parseInt(str[1]);
  28. x6=Integer.parseInt(str[2]);
  29. y6=Integer.parseInt(str[3]);
  30. boolean fl=false;
  31. 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
  32. inside that gap also, i is incremented by 0.5
  33. { if(f(i,y1)==0)
  34. { fl=true;
  35. break;
  36. }
  37. if(f(i,y2)==0)
  38. { fl=true;
  39. break;
  40. }
  41. }//this for loop is to check the points on horizontal boundaries of white sheet
  42. for(double i=y1;i<=y2;i+=0.5)
  43. { if(f(x1,i)==0)
  44. { fl=true;
  45. break;
  46. }
  47. if(f(x2,i)==0)
  48. { fl=true;
  49. break;
  50. }
  51. }//this for loop is to check the points on vertical boundaries of white sheet
  52. if(fl==true)
  53. System.out.print("YES");
  54. else
  55. System.out.print("NO");
  56. }
  57. }
Add Comment
Please, Sign In to add comment