Advertisement
MiinaMagdy

10242 - Fourth Point !!

Apr 17th, 2023
726
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.59 KB | None | 0 0
  1. /*
  2. +---------------------------------------------+
  3. |                                             |
  4. |       © 17/04/2023 (18:14) MinaMagdy        |
  5. |                                             |
  6. +---------------------------------------------+
  7. */
  8. #include <bits/stdc++.h>
  9. #include <ext/pb_ds/assoc_container.hpp>
  10. #include <ext/pb_ds/tree_policy.hpp>
  11.  
  12. using namespace std;
  13. using namespace __gnu_pbds;
  14. #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
  15. #define multi_ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
  16. #define endl "\n"
  17. #define MOD 1000000007
  18. #define INF 2000000000
  19. #define all(s) s.begin(), s.end()
  20. #define rall(s) s.rbegin(), s.rend()
  21. #define sz(x) int(x.size())
  22.  
  23. typedef long long ll;
  24. typedef long double ld;
  25. typedef unsigned long long ull;
  26. // --------------------------->         GEOMETRY         <---------------------------    
  27. #define EPS 1e-9
  28. #define PI acos(-1)
  29. #define X real()
  30. #define Y imag()
  31. #define angle(a) atan2(a.Y, a.X)
  32. #define vec(a, b) point((b) - (a))
  33. #define length(a) hypot(a.Y, a.X)
  34. #define normalize(a) (a) / length(a)
  35. #define dot_prod(a, b) real(conj(a) * (b))
  36. #define cross_prod(a, b) imag(conj(a) * (b))
  37. #define lengthSqr(p) dot_prod(p, p)
  38. #define rotateO(p, ang) p * exp(point(0, ang))
  39. #define rotateA(p, about, ang) rotateO(vec((about), (p)), ang) + (about)
  40. #define reflicatO(v, m) conj(v / m) * m
  41. #define reflicatA(v, about, m) conj(vec(about, v) / vec(about, m)) * vec(about, m) + about
  42.  
  43. typedef complex<ld> point;
  44. bool cin_point(point &p) {
  45.     double x = -INF, y = -INF;
  46.     cin >> x >> y;
  47.     p = {x, y};
  48.     return x != -INF or y != -INF;
  49. }
  50.  
  51. void solve() {
  52.     ld x1, y1, x2, y2, x3, y3, x4, y4;
  53.     while (scanf("%Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4) != EOF) {
  54.         vector<point> p = {{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}};
  55.         sort(all(p), [](point a, point b) {
  56.             if (a.X == b.X) return a.Y < b.Y;
  57.             return a.X < b.X;
  58.         });
  59.         point ans;
  60.         if (p[0] == p[1]) {
  61.             ans = p[2] + p[3] - p[0];
  62.         }
  63.         else if (p[1] == p[2]) {
  64.             ans = p[0] + p[3] - p[1];
  65.         }
  66.         else if (p[2] == p[3]) {
  67.             ans = p[0] + p[1] - p[2];
  68.         }
  69.         cout << fixed << setprecision(3) << ans.X << " " << ans.Y << endl;
  70.     }
  71. }
  72.  
  73. int main(void)
  74. {
  75.     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  76.     int testcase = 1;
  77.     // cin >> testcase;
  78.     while (testcase--)
  79.         solve();
  80.     return 0;
  81. }
Tags: UVA
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement