Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <clocale>
  3. #include <bits/stdc++.h>
  4.  
  5. #pragma GCC optimize("Ofast")
  6. #pragma GCC optimize("O3")
  7.  
  8. using namespace std;
  9.  
  10. #define ll long long
  11.  
  12. const int inf = (int)2e9;
  13. const int mod = (int)1e9 + 7;
  14. const double error = 1e-5;
  15.  
  16. struct point {
  17.  
  18. int x, y;
  19.  
  20. point() {
  21. x = inf;
  22. y = inf;
  23. }
  24.  
  25. point(int _x, int _y) {
  26. x = _x;
  27. y = _y;
  28. }
  29.  
  30. bool operator < (point &other) const {
  31.  
  32. if(x != other.x) {
  33. return x < other.x;
  34. }
  35.  
  36. return y < other.y;
  37. }
  38. };
  39.  
  40. int sqr(int a) {
  41. return a * a;
  42. }
  43.  
  44. int dist(point a, point b) {
  45. return sqr(a.x - b.x) + sqr(a.y - b.y);
  46. }
  47.  
  48. int main() {
  49. freopen("quadr.in", "r", stdin);
  50. freopen("quadr.out", "w", stdout);
  51.  
  52. vector <point> p(4);
  53.  
  54. for(point &cur: p) {
  55. scanf("%d%d", &cur.x, &cur.y);
  56. }
  57.  
  58. do {
  59.  
  60. int d0 = dist(p[0], p[1]);
  61. int d1 = dist(p[1], p[2]);
  62. int d2 = dist(p[2], p[3]);
  63. int d3 = dist(p[3], p[0]);
  64. int diag0 = dist(p[0], p[2]);
  65. int diag1 = dist(p[1], p[3]);
  66.  
  67. if(d0 == d1 && d1 == d2 && d2 == d3 && d3 == d0 && diag0 == diag1 && d0 != 0) {
  68. return printf("YES"), 0;
  69. }
  70.  
  71. }while(next_permutation(p.begin(), p.end()));
  72.  
  73. printf("NO");
  74.  
  75. return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement