fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. typedef string str;
  5. struct rec{
  6. ll x1,y1,x2,y2;
  7. ll area(){//calculates area
  8. return (x2-x1)*(y2-y1);
  9. }
  10. };
  11. ll intersection(rec a, rec b){//calculates area of intersection of 2 rectangles
  12. ll xoverlap=max((ll)0,min(a.x2,b.x2)-max(a.x1,b.x1));
  13. ll yoverlap=max((ll)0,min(a.y2,b.y2)-max(a.y1,b.y1));
  14. return xoverlap*yoverlap;
  15. }
  16. ll special(rec a, rec b){//calculates the the coordinates of the rectangle
  17. // formed by the intersection of the 2 black sheets
  18. //and then uses that to determine the area of intersection of this rectangle with the white sheet
  19. ll xoverlap=max((ll)0,min(a.x2,b.x2)-max(a.x1,b.x1));
  20. ll yoverlap=max((ll)0,min(a.y2,b.y2)-max(a.y1,b.y1));
  21. rec c;
  22. c.x1=max(a.x1,b.x1),c.y1=max(a.y1,b.y1),c.x2=min(a.y2,b.y2),c.y2=min(a.x2,b.x2);
  23. return intersection(c,a);
  24. }
  25.  
  26. int main(){
  27. ios::sync_with_stdio(0);
  28. cin.tie(0);cout.tie(0);
  29. rec a,b,t;
  30. cin>>a.x1>>a.y1>>a.x2>>a.y2;
  31. cin>>b.x1>>b.y1>>b.x2>>b.y2;
  32. cin>>t.x1>>t.y1>>t.x2>>t.y2;
  33. if(a.area()>intersection(b,a)+intersection(t,a)-special(b,t)) cout<<"YES"; //if area of white sheet is greater
  34. //than the area covered by the black sheets
  35. else cout<<"NO";
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
YES