Advertisement
7oSkaaa

I

Feb 25th, 2023
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.82 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define fixed(n) fixed << setprecision(n)
  6. #define ceil(n, m) (((n) + (m) - 1) / (m))
  7. #define add_mod(a, b, m) (((a % m) + (b % m)) % m)
  8. #define sub_mod(a, b, m) (((a % m) - (b % m) + m) % m)
  9. #define mul_mod(a, b, m) (((a % m) * (b % m)) % m)
  10. #define all(vec) vec.begin(), vec.end()
  11. #define rall(vec) vec.rbegin(), vec.rend()
  12. #define sz(x) int(x.size())
  13. #define debug(x) cout << #x << ": " << (x) << "\n";
  14. #define fi first
  15. #define se second
  16. #define ll long long
  17. #define ull unsigned long long
  18. #define EPS 1e-9
  19. constexpr int INF = 1 << 30, Mod = 1e9 + 7;
  20. constexpr ll LINF = 1LL << 62;
  21. #define PI acos(-1)
  22. template < typename T = int > using Pair = pair < T, T >;
  23. vector < string > RET = {"NO", "YES"};
  24.  
  25. template < typename T = int > istream& operator >> (istream &in, vector < T > &v) {
  26.     for (auto &x : v) in >> x;
  27.     return in;
  28. }
  29.  
  30. template < typename T = int > ostream& operator << (ostream &out, const vector < T > &v) {
  31.     for (const T &x : v) out << x << ' ';
  32.     return out;
  33. }
  34.  
  35. typedef complex < double > point;
  36. #define X real()
  37. #define Y imag()
  38. #define angle(a)                (atan2((a).imag(), (a).real()))
  39. #define vec(a, b)                ((b)-(a))
  40. #define same(p1, p2)             (dp(vec(p1, p2), vec(p1,p2)) < EPS)
  41. #define dp(a, b)                 ( (conj(a) * (b)).real() ) // a * b cos(T), if zero -> prep
  42. #define cp(a, b)                 ( (conj(a) * (b)).imag() ) // a * b sin(T), if zero -> parllel
  43. #define length(a)               (hypot((a).imag(), (a).real()))
  44. #define normalize(a)            (a) / length(a)
  45. #define polar(r, ang)            ((r) * exp(point(0, ang)))
  46. #define rotateO(p, ang)          ((p) * exp(point(0, ang)))
  47. #define rotateA(p, ang, about)  (rotateO(vec(about, p), ang) + about)
  48. int dcmp(double a, double b) { return fabs(a - b) <= EPS ? 0 : a < b ? -1 : 1; }
  49.  
  50. istream& operator >> (istream &in, point& p) {
  51.     double x, y;
  52.     in >> x >> y;
  53.     p = point(x, y);
  54.     return in;
  55. }
  56.  
  57. ostream& operator << (ostream &out, const point& p) {
  58.     out << p.X << ' ' << p.Y;
  59.     return out;
  60. }
  61.  
  62. double dist(point& a, point& b) {
  63.     return hypot(a.X - b.X, a.Y - b.Y);
  64. }
  65.  
  66. double TriangleArea(point& a, point& b, point& c) {
  67.     return fabs(cp(b - a, c - a)) / 2.0;
  68. }
  69.  
  70. void Solve(){
  71.     int n;
  72.     cin >> n;
  73.     point S;
  74.     cin >> S;
  75.     deque < point > P(n);
  76.     for(auto& p : P)
  77.         cin >> p;
  78.     sort(all(P), [&](point& a, point& b) {
  79.         return dist(S, a) < dist(S, b);
  80.     });
  81.     double MaxArea = 0;
  82.     vector < int > next(n, -1), nextnext(n, -1);
  83.     for(int i = 0; i < n; i++){
  84.         for(int j = 0; j < n; j++){
  85.             if(i == j) continue;
  86.             double distA = dist(P[i], P[j]);
  87.             if(next[i] == -1)
  88.                 next[i] = j;
  89.             else if(distA < dist(P[i], P[next[i]]))
  90.                 nextnext[i] = next[i], next[i] = j;
  91.             else if(nextnext[i] == -1 || distA < dist(P[i], P[nextnext[i]]))
  92.                 nextnext[i] = j;
  93.         }
  94.     }
  95.     vector < bool > is_removed(n, false);
  96.     for(int i = 0; i < n; i++){
  97.         is_removed[i] = true;
  98.         double MinArea = 1e18;
  99.         for(int j = 0; j < n; j++){
  100.             if(i == j) continue;
  101.             if(!is_removed[next[j]])
  102.                 MinArea = min(MinArea, TriangleArea(S, P[j], P[next[j]]));
  103.             else
  104.                 MinArea = min(MinArea, TriangleArea(S, P[j], P[nextnext[j]]));
  105.         }
  106.         MaxArea = max(MaxArea, MinArea);
  107.         is_removed[i] = false;
  108.     }
  109.     cout << fixed(10) << MaxArea << '\n';
  110. }
  111.  
  112. int main(){
  113.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  114.     int test_cases = 1;
  115.     // cin >> test_cases;
  116.     for(int tc = 1; tc <= test_cases; tc++){
  117.         // cout << "Case #" << tc << ": ";
  118.         Solve();
  119.     }
  120.     return 0;
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement