Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include<vector>
  2. #include<iomanip>
  3. #include<iostream>
  4. #include<cmath>
  5. #include<algorithm>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. int main() {
  11. int x1,y1,x2,y2,x3,y3,x4,y4,kos1,kos2;
  12. cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
  13.  
  14. int p13x = x3 - x1;
  15. int p13y = y3 - y1;
  16. int p12x = x2 - x1;
  17. int p12y = y2 - y1;
  18. int p14x = x4 - x1;
  19. int p14y = y4 - y1;
  20. int p34x = x4 - x3;
  21. int p34y = y4 - y3;
  22. int p32x = x2 - x3;
  23. int p32y = y2 - y3;
  24.  
  25. kos1 = (p13x * p12y - p13y * p12x) * (p14x * p12y - p14y * p12x);
  26. kos2 = ((-p13x) * p34y - (-p13y) * p34x) * (p32x * p34y - p32y * p34x);
  27.  
  28. if (x1 < x2) {
  29. int tmp = x1;
  30. x1 = x2;
  31. x2 = tmp;
  32. }
  33.  
  34. if (y1 < y2) {
  35. int tmp = y1;
  36. y1 = y2;
  37. y2 = tmp;
  38. }
  39.  
  40. if (x3 < x4) {
  41. int tmp = x3;
  42. x3 = x4;
  43. x4 = tmp;
  44. }
  45.  
  46. if (y3 < y4) {
  47. int tmp = y3;
  48. y3 = y4;
  49. y4 = tmp;
  50. }
  51.  
  52. if (x1 >= x4 && x3 >= x2 && y1 >= y4 && y3 >= y2 && kos1 <= 0 && kos2 <=0) cout << "YES";
  53. else cout << "NO";
  54.  
  55.  
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement