結果
| 問題 |
No.2331 Maximum Quadrilateral
|
| コンテスト | |
| ユーザー |
hamath
|
| 提出日時 | 2023-05-28 16:40:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 25,582 bytes |
| コンパイル時間 | 4,531 ms |
| コンパイル使用メモリ | 262,924 KB |
| 最終ジャッジ日時 | 2025-02-13 15:24:26 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 WA * 5 TLE * 14 |
ソースコード
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#else
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#endif
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<VP> VVP;
typedef vector<Vec> VV;
typedef vector<Vi> VVi;
typedef vector<Vc> VVc;
typedef vector<VV> VVV;
typedef vector<VVV> VVVV;
#define MAKEVV(variable, a, ...) VV variable(a, Vec(__VA_ARGS__))
#define MAKEVVc(variable, a, ...) VVc variable(a,Vc(__VA_ARGS__))
#define MAKEVVV(variable, a, b, ...) VVV variable(a, VV(b, Vec(__VA_ARGS__)))
#define MAKEVVVV(variable, a, b, c, ...) VVVV variable(a, VVV(b, (VV(c, Vec(__VA_ARGS__)))))
#define endl '\n'
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 4'000'000'000'000'000'010LL;
const ll MOD=998244353;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#define SUM(a) accumulate(ALL(a),0LL)
#define outminusone(a) cout<< ( a==INF ? -1 : a ) <<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>auto lb(vector<T> &X, T x){return lower_bound(ALL(X),x) - X.begin();}
template<class T>auto ub(vector<T> &X, T x){return upper_bound(ALL(X),x) - X.begin();}
ll popcnt(ll x){return __builtin_popcount(x);}
ll topbit(ll t){return t==0?-1:63-__builtin_clzll(t);}
ll floor(ll y,ll x){assert(x != 0);if(x < 0){y *= -1; x *= -1;}if(y < 0){return (y-x+1)/x;}return y/x;};
ll ceil(ll y, ll x){assert(x != 0);if(x < 0){y *= -1; x *= -1;}if(y < 0){return y/x;}return (y+x-1)/x;};
template<typename T1, typename T2>istream &operator>>(istream &i, pair<T1, T2> &p) { return i>>p.first>>p.second; }
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,v.size())i>>v[j];return i;}
template<typename T1, typename T2>ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }
template<class T>ostream &operator<<(ostream &os, const vector<T> &v) {bool f = false;for(const auto &d: v) {if(f) os<<" ";f = true;os<<d;}return os;}
template <class T> ostream& operator<<(ostream& os, const set<T>& s) {os << "{";bool f = false;for (auto d : s) {if (f) os << ", ";f = true;os << d;}return os << "}";}
template <class T> ostream& operator<<(ostream& os, const multiset<T>& s) {os << "{";bool f = false;for (auto d : s) {if (f) os << ", ";f = true;os << d;}return os << "}";}
template<class T, class U>ostream &operator<<(ostream &os, const map<T, U> &s) {bool f = false;os<<endl;for(auto p: s) {if(f) os<<endl;f = true;os<<p.first<<": "<<p.second;}return os<<endl;}
void out() { cout << endl; }
template <class Head, class... Tail> void out(const Head &head, const Tail &...tail) {cout << head;if(sizeof...(tail)) cout << ' ';out(tail...);}
#ifdef LOCAL
template<typename T>ostream &operator<<(ostream &s, const vector<vector<T>> &vv) {int len=vv.size();for(int i=0; i<len; ++i) {if(i==0)s<<endl;s<<i<<":"<<vv[i];if(i!=len-1)s<<endl;}return s;}
struct PrettyOS {ostream& os;bool first;template <class T> auto operator<<(T&& x) {if (!first) os << ", ";first = false;os << x;return *this;}};
template <class... T> void dbg0(T&&... t) {(PrettyOS{cerr, true} << ... << t);}
#define dbg(...)do {cerr << #__VA_ARGS__ << ": ";dbg0(__VA_ARGS__);cerr << endl;} while (false);
#else
#define dbg(...)
#endif
template <class T>
struct Matrix {
vector<vector<T>> A;
Matrix() = default;
Matrix(int n, int m) : A(n, vector<T>(m, T())) {}
Matrix(int n) : A(n, vector<T>(n, T())){};
int H() const { return A.size(); }
int W() const { return A[0].size(); }
int size() const { return A.size(); }
inline const vector<T> &operator[](int k) const { return A[k]; }
inline vector<T> &operator[](int k) { return A[k]; }
static Matrix I(int n) {
Matrix mat(n);
for (int i = 0; i < n; i++) mat[i][i] = 1;
return (mat);
}
Matrix &operator+=(const Matrix &B) {
int n = H(), m = W();
assert(n == B.H() && m == B.W());
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) (*this)[i][j] += B[i][j];
return (*this);
}
Matrix &operator-=(const Matrix &B) {
int n = H(), m = W();
assert(n == B.H() && m == B.W());
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) (*this)[i][j] -= B[i][j];
return (*this);
}
Matrix &operator*=(const Matrix &B) {
int n = H(), m = B.W(), p = W();
assert(p == B.H());
vector<vector<T> > C(n, vector<T>(m, T{}));
for (int i = 0; i < n; i++)
for (int k = 0; k < p; k++)
for (int j = 0; j < m; j++) C[i][j] += (*this)[i][k] * B[k][j];
A.swap(C);
return (*this);
}
Matrix &operator^=(long long k) {
Matrix B = Matrix::I(H());
while (k > 0) {
if (k & 1) B *= *this;
*this *= *this;
k >>= 1LL;
}
A.swap(B.A);
return (*this);
}
Matrix operator+(const Matrix &B) const { return (Matrix(*this) += B); }
Matrix operator-(const Matrix &B) const { return (Matrix(*this) -= B); }
Matrix operator*(const Matrix &B) const { return (Matrix(*this) *= B); }
Matrix operator^(const long long k) const { return (Matrix(*this) ^= k); }
bool operator==(const Matrix &B) const {
assert(H() == B.H() && W() == B.W());
for (int i = 0; i < H(); i++)
for (int j = 0; j < W(); j++)
if (A[i][j] != B[i][j]) return false;
return true;
}
bool operator!=(const Matrix &B) const {
assert(H() == B.H() && W() == B.W());
for (int i = 0; i < H(); i++)
for (int j = 0; j < W(); j++)
if (A[i][j] != B[i][j]) return true;
return false;
}
friend ostream &operator<<(ostream &os, const Matrix &p) {
int n = p.H(), m = p.W();
for (int i = 0; i < n; i++) {
os << (i ? " " : "") << "[";
for (int j = 0; j < m; j++) {
os << p[i][j] << (j + 1 == m ? "]\n" : ",");
}
}
return (os);
}
T determinant() const {
Matrix B(*this);
assert(H() == W());
T ret = 1;
for (int i = 0; i < H(); i++) {
int idx = -1;
for (int j = i; j < W(); j++) {
if (B[j][i] != 0) {
idx = j;
break;
}
}
if (idx == -1) return 0;
if (i != idx) {
ret *= T(-1);
swap(B[i], B[idx]);
}
ret *= B[i][i];
T inv = T(1) / B[i][i];
for (int j = 0; j < W(); j++) {
B[i][j] *= inv;
}
for (int j = i + 1; j < H(); j++) {
T a = B[j][i];
if (a == 0) continue;
for (int k = i; k < W(); k++) {
B[j][k] -= B[i][k] * a;
}
}
}
return ret;
}
};
using Real = ld;
using Point = complex< Real >;
const Real EPS = 1e-8, PI = acos(-1);
inline bool eq(Real a, Real b) { return fabs(b - a) < EPS; }
Point operator*(const Point &p, const Real &d) {
return Point(real(p) * d, imag(p) * d);
}
istream &operator>>(istream &is, Point &p) {
Real a, b;
is >> a >> b;
p = Point(a, b);
return is;
}
ostream &operator<<(ostream &os, Point &p) {
return os << fixed << setprecision(10) << p.real() << " " << p.imag();
}
// rotate point p counterclockwise by theta rad
Point rotate(Real theta, const Point &p) {
return Point(cos(theta) * p.real() - sin(theta) * p.imag(), sin(theta) * p.real() + cos(theta) * p.imag());
}
Real radian_to_degree(Real r) {
return (r * 180.0 / PI);
}
Real degree_to_radian(Real d) {
return (d * PI / 180.0);
}
// smaller angle of the a-b-c
Real get_angle(const Point &a, const Point &b, const Point &c) {
const Point v(b - a), w(c - b);
Real alpha = atan2(v.imag(), v.real()), beta = atan2(w.imag(), w.real());
if(alpha > beta) swap(alpha, beta);
Real theta = (beta - alpha);
//return min(theta, 2 * acos(-1) - theta);
return theta;
}
Real angle(const Point &a) {
Real angle = atan2(a.imag(),a.real());
if(angle < 0) angle += PI*2;
return angle;
}
namespace std {
bool operator<(const Point &a, const Point &b) {
return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
}
}
struct Line {
Point a, b;
Line() = default;
Line(Point a, Point b) : a(a), b(b) {}
Line(Real A, Real B, Real C) // Ax + By = C
{
if(eq(A, 0)) a = Point(0, C / B), b = Point(1, C / B);
else if(eq(B, 0)) b = Point(C / A, 0), b = Point(C / A, 1);
else a = Point(0, C / B), b = Point(C / A, 0);
}
friend ostream &operator<<(ostream &os, Line &p) {
return os << p.a << " to " << p.b;
}
friend istream &operator>>(istream &is, Line &a) {
return is >> a.a >> a.b;
}
};
struct Segment : Line {
Segment() = default;
Segment(Point a, Point b) : Line(a, b) {}
};
struct Circle {
Point p;
Real r;
Circle() = default;
Circle(Point p, Real r) : p(p), r(r) {}
};
using Points = vector< Point >;
using Polygon = vector< Point >;
using Segments = vector< Segment >;
using Lines = vector< Line >;
using Circles = vector< Circle >;
Real cross(const Point &a, const Point &b) {
return real(a) * imag(b) - imag(a) * real(b);
}
Real dot(const Point &a, const Point &b) {
return real(a) * real(b) + imag(a) * imag(b);
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C
int ccw(const Point &a, Point b, Point c) {
b = b - a, c = c - a;
if(cross(b, c) > EPS) return +1; // "COUNTER_CLOCKWISE"
if(cross(b, c) < -EPS) return -1; // "CLOCKWISE"
if(dot(b, c) < 0) return +2; // "ONLINE_BACK" c-a-b
if(norm(b) < norm(c)) return -2; // "ONLINE_FRONT" a-b-c
return 0; // "ON_SEGMENT" a-c-b
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A
bool parallel(const Line &a, const Line &b) {
return eq(cross(a.b - a.a, b.b - b.a), 0.0);
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A
bool orthogonal(const Line &a, const Line &b) {
return eq(dot(a.a - a.b, b.a - b.b), 0.0);
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A
Point projection(const Line &l, const Point &p) {
double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
return l.a + (l.a - l.b) * t;
}
Point projection(const Segment &l, const Point &p) {
double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
return l.a + (l.a - l.b) * t;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B
Point reflection(const Line &l, const Point &p) {
return p + (projection(l, p) - p) * 2.0;
}
bool intersect(const Line &l, const Point &p) {
return abs(ccw(l.a, l.b, p)) != 1;
}
bool intersect(const Line &l, const Line &m) {
return abs(cross(l.b - l.a, m.b - m.a)) > EPS || abs(cross(l.b - l.a, m.b - l.a)) < EPS;
}
bool intersect(const Segment &s, const Point &p) {
return ccw(s.a, s.b, p) == 0;
}
bool intersect(const Line &l, const Segment &s) {
return cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < EPS;
}
Real distance(const Line &l, const Point &p);
bool intersect(const Circle &c, const Line &l) {
return distance(l, c.p) <= c.r + EPS;
}
bool intersect(const Circle &c, const Point &p) {
return abs(abs(p - c.p) - c.r) < EPS;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_B
bool intersect(const Segment &s, const Segment &t) {
return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
int intersect(const Circle &c, const Segment &l) {
if(norm(projection(l, c.p) - c.p) - c.r * c.r > EPS) return 0;
auto d1 = abs(c.p - l.a), d2 = abs(c.p - l.b);
if(d1 < c.r + EPS && d2 < c.r + EPS) return 0;
if(d1 < c.r - EPS && d2 > c.r + EPS || d1 > c.r + EPS && d2 < c.r - EPS) return 1;
const Point h = projection(l, c.p);
if(dot(l.a - h, l.b - h) < 0) return 2;
return 0;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_A&lang=jp
int intersect(Circle c1, Circle c2) {
if(c1.r < c2.r) swap(c1, c2);
Real d = abs(c1.p - c2.p);
if(c1.r + c2.r < d) return 4;
if(eq(c1.r + c2.r, d)) return 3;
if(c1.r - c2.r < d) return 2;
if(eq(c1.r - c2.r, d)) return 1;
return 0;
}
Real distance(const Point &a, const Point &b) {
return abs(a - b);
}
Real distance(const Line &l, const Point &p) {
return abs(p - projection(l, p));
}
Real distance(const Line &l, const Line &m) {
return intersect(l, m) ? 0 : distance(l, m.a);
}
Real distance(const Segment &s, const Point &p) {
Point r = projection(s, p);
if(intersect(s, r)) return abs(r - p);
return min(abs(s.a - p), abs(s.b - p));
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_D
Real distance(const Segment &a, const Segment &b) {
if(intersect(a, b)) return 0;
return min({distance(a, b.a), distance(a, b.b), distance(b, a.a), distance(b, a.b)});
}
Real distance(const Line &l, const Segment &s) {
if(intersect(l, s)) return 0;
return min(distance(l, s.a), distance(l, s.b));
}
Point crosspoint(const Line &l, const Line &m) {
Real A = cross(l.b - l.a, m.b - m.a);
Real B = cross(l.b - l.a, l.b - m.a);
if(eq(abs(A), 0.0) && eq(abs(B), 0.0)) return m.a;
return m.a + (m.b - m.a) * B / A;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_C
Point crosspoint(const Segment &l, const Segment &m) {
return crosspoint(Line(l), Line(m));
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_D
pair< Point, Point > crosspoint(const Circle &c, const Line l) {
Point pr = projection(l, c.p);
Point e = (l.b - l.a) / abs(l.b - l.a);
if(eq(distance(l, c.p), c.r)) return {pr, pr};
double base = sqrt(c.r * c.r - norm(pr - c.p));
return {pr - e * base, pr + e * base};
}
pair< Point, Point > crosspoint(const Circle &c, const Segment &l) {
Line aa = Line(l.a, l.b);
if(intersect(c, l) == 2) return crosspoint(c, aa);
auto ret = crosspoint(c, aa);
if(dot(l.a - ret.first, l.b - ret.first) < 0) ret.second = ret.first;
else ret.first = ret.second;
return ret;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_E
pair< Point, Point > crosspoint(const Circle &c1, const Circle &c2) {
Real d = abs(c1.p - c2.p);
Real a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
Real t = atan2(c2.p.imag() - c1.p.imag(), c2.p.real() - c1.p.real());
Point p1 = c1.p + Point(cos(t + a) * c1.r, sin(t + a) * c1.r);
Point p2 = c1.p + Point(cos(t - a) * c1.r, sin(t - a) * c1.r);
return {p1, p2};
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_F
// tangent of circle c through point p
pair< Point, Point > tangent(const Circle &c1, const Point &p2) {
return crosspoint(c1, Circle(p2, sqrt(norm(c1.p - p2) - c1.r * c1.r)));
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_G
// common tangent of circles c1 and c2
Lines tangent(Circle c1, Circle c2) {
Lines ret;
if(c1.r < c2.r) swap(c1, c2);
Real g = norm(c1.p - c2.p);
if(eq(g, 0)) return ret;
Point u = (c2.p - c1.p) / sqrt(g);
Point v = rotate(PI * 0.5, u);
for(int s : {-1, 1}) {
Real h = (c1.r + s * c2.r) / sqrt(g);
if(eq(1 - h * h, 0)) {
ret.emplace_back(c1.p + u * c1.r, c1.p + (u + v) * c1.r);
} else if(1 - h * h > 0) {
Point uu = u * h, vv = v * sqrt(1 - h * h);
ret.emplace_back(c1.p + (uu + vv) * c1.r, c2.p - (uu + vv) * c2.r * s);
ret.emplace_back(c1.p + (uu - vv) * c1.r, c2.p - (uu - vv) * c2.r * s);
}
}
return ret;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_B
bool is_convex(const Polygon &p) {
int n = (int) p.size();
for(int i = 0; i < n; i++) {
if(ccw(p[(i + n - 1) % n], p[i], p[(i + 1) % n]) == -1) return false;
}
return true;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_4_A
Polygon convex_hull(Polygon &p) {
int n = (int) p.size(), k = 0;
if(n <= 2) return p;
sort(p.begin(), p.end());
vector< Point > ch(2 * n);
for(int i = 0; i < n; ch[k++] = p[i++]) {
while(k >= 2 && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < EPS) --k;
}
for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]) {
while(k >= t && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < EPS) --k;
}
ch.resize(k - 1);
return ch;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_C
enum {
OUT, ON, IN
};
int contains(const Polygon &Q, const Point &p) {
bool in = false;
for(int i = 0; i < Q.size(); i++) {
Point a = Q[i] - p, b = Q[(i + 1) % Q.size()] - p;
if(a.imag() > b.imag()) swap(a, b);
if(a.imag() <= 0 && 0 < b.imag() && cross(a, b) < 0) in = !in;
if(cross(a, b) == 0 && dot(a, b) <= 0) return ON;
}
return in ? IN : OUT;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0412
int convex_contains(const Polygon &Q, const Point &p) {
int N = (int) Q.size();
Point g = (Q[0] + Q[N / 3] + Q[N * 2 / 3]) / (Real)3.0;
if(g == p) return IN;
Point gp = p - g;
int l = 0, r = N;
while(r - l > 1) {
int mid = (l + r) / 2;
Point gl = Q[l] - g;
Point gm = Q[mid] - g;
if(cross(gl, gm) > 0) {
if(cross(gl, gp) >= 0 && cross(gm, gp) <= 0) r = mid;
else l = mid;
} else {
if(cross(gl, gp) <= 0 && cross(gm, gp) >= 0) l = mid;
else r = mid;
}
}
r %= N;
Real v = cross(Q[l] - p, Q[r] - p);
return eq(v, 0.0) ? ON : v < 0.0 ? OUT : IN;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1033
// deduplication of line segments
void merge_segments(vector< Segment > &segs) {
auto merge_if_able = [](Segment &s1, const Segment &s2) {
if(abs(cross(s1.b - s1.a, s2.b - s2.a)) > EPS) return false;
if(ccw(s1.a, s2.a, s1.b) == 1 || ccw(s1.a, s2.a, s1.b) == -1) return false;
if(ccw(s1.a, s1.b, s2.a) == -2 || ccw(s2.a, s2.b, s1.a) == -2) return false;
s1 = Segment(min(s1.a, s2.a), max(s1.b, s2.b));
return true;
};
for(int i = 0; i < segs.size(); i++) {
if(segs[i].b < segs[i].a) swap(segs[i].a, segs[i].b);
}
for(int i = 0; i < segs.size(); i++) {
for(int j = i + 1; j < segs.size(); j++) {
if(merge_if_able(segs[i], segs[j])) {
segs[j--] = segs.back(), segs.pop_back();
}
}
}
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1033
// construct a graph with the vertex of the intersection of any two line segments
vector< vector< int > > segment_arrangement(vector< Segment > &segs, vector< Point > &ps) {
vector< vector< int > > g;
int N = (int) segs.size();
for(int i = 0; i < N; i++) {
ps.emplace_back(segs[i].a);
ps.emplace_back(segs[i].b);
for(int j = i + 1; j < N; j++) {
const Point p1 = segs[i].b - segs[i].a;
const Point p2 = segs[j].b - segs[j].a;
if(cross(p1, p2) == 0) continue;
if(intersect(segs[i], segs[j])) {
ps.emplace_back(crosspoint(segs[i], segs[j]));
}
}
}
sort(begin(ps), end(ps));
ps.erase(unique(begin(ps), end(ps)), end(ps));
int M = (int) ps.size();
g.resize(M);
for(int i = 0; i < N; i++) {
vector< int > vec;
for(int j = 0; j < M; j++) {
if(intersect(segs[i], ps[j])) {
vec.emplace_back(j);
}
}
for(int j = 1; j < vec.size(); j++) {
g[vec[j - 1]].push_back(vec[j]);
g[vec[j]].push_back(vec[j - 1]);
}
}
return (g);
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_4_C
// cut with a straight line l and return a convex polygon on the left
Polygon convex_cut(const Polygon &U, Line l) {
Polygon ret;
for(int i = 0; i < U.size(); i++) {
Point now = U[i], nxt = U[(i + 1) % U.size()];
if(ccw(l.a, l.b, now) != -1) ret.push_back(now);
if(ccw(l.a, l.b, now) * ccw(l.a, l.b, nxt) < 0) {
ret.push_back(crosspoint(Line(now, nxt), l));
}
}
return (ret);
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_A
Real area(const Polygon &p) {
Real A = 0;
for(int i = 0; i < p.size(); ++i) {
A += cross(p[i], p[(i + 1) % p.size()]);
}
return A * 0.5;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_H
Real area(const Polygon &p, const Circle &c) {
if(p.size() < 3) return 0.0;
function< Real(Circle, Point, Point) > cross_area = [&](const Circle &c, const Point &a, const Point &b) {
Point va = c.p - a, vb = c.p - b;
Real f = cross(va, vb), ret = 0.0;
if(eq(f, 0.0)) return ret;
if(max(abs(va), abs(vb)) < c.r + EPS) return f;
if(distance(Segment(a, b), c.p) > c.r - EPS) return c.r * c.r * arg(vb * conj(va));
auto u = crosspoint(c, Segment(a, b));
vector< Point > tot{a, u.first, u.second, b};
for(int i = 0; i + 1 < tot.size(); i++) {
ret += cross_area(c, tot[i], tot[i + 1]);
}
return ret;
};
Real A = 0;
for(int i = 0; i < p.size(); i++) {
A += cross_area(c, p[i], p[(i + 1) % p.size()]);
}
return A;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_4_B
Real convex_diameter(const Polygon &p) {
int N = (int) p.size();
int is = 0, js = 0;
for(int i = 1; i < N; i++) {
if(p[i].imag() > p[is].imag()) is = i;
if(p[i].imag() < p[js].imag()) js = i;
}
Real maxdis = norm(p[is] - p[js]);
int maxi, maxj, i, j;
i = maxi = is;
j = maxj = js;
do {
if(cross(p[(i + 1) % N] - p[i], p[(j + 1) % N] - p[j]) >= 0) {
j = (j + 1) % N;
} else {
i = (i + 1) % N;
}
if(norm(p[i] - p[j]) > maxdis) {
maxdis = norm(p[i] - p[j]);
maxi = i;
maxj = j;
}
} while(i != is || j != js);
return sqrt(maxdis);
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_5_A
Real closest_pair(Points ps) {
if(ps.size() <= 1) throw (0);
sort(begin(ps), end(ps));
auto compare_y = [&](const Point &a, const Point &b) {
return imag(a) < imag(b);
};
vector< Point > beet(ps.size());
const Real INF = 1e18;
function< Real(int, int) > rec = [&](int left, int right) {
if(right - left <= 1) return INF;
int mid = (left + right) >> 1;
auto x = real(ps[mid]);
auto ret = min(rec(left, mid), rec(mid, right));
inplace_merge(begin(ps) + left, begin(ps) + mid, begin(ps) + right, compare_y);
int ptr = 0;
for(int i = left; i < right; i++) {
if(abs(real(ps[i]) - x) >= ret) continue;
for(int j = 0; j < ptr; j++) {
auto luz = ps[i] - beet[ptr - j - 1];
if(imag(luz) >= ret) break;
ret = min(ret, abs(luz));
}
beet[ptr++] = ps[i];
}
return ret;
};
return rec(0, (int) ps.size());
}
int solve(){
/*
* 2点選ぶ。等積変形?
*
*/
ll n;
cin>>n;
VP vp(n);
cin>>vp;
/*
*
*/
ll ans = 0;
rep(j,n){
rep(i,j){
auto [x,y] = vp[i];
auto [nx,ny] = vp[j];
Line l = Line(Point(x,y), Point(nx,ny));
vector<ld> v;
rep(k,n){
auto [tx,ty] = vp[k];
ld dist = distance(l, Point(tx,ty));
ll dir = ccw(Point(x,y),Point(nx,ny),Point(tx,ty));
if(dir == 1){
v.pb(dist);
}else if(dir == -1){
v.pb(-dist);
}else{
v.pb(dist);
}
}
sort(ALL(v));
ld tmp = distance(Point(x,y),Point(nx,ny)) * (v[v.size()-1] - v[0]);
tmp += 1e-8;
chmax(ans, (ll)tmp);
}
}
out(ans);
return 0;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout<<std::setprecision(20);
// ll T;
// cin>>T;
// while(T--)
solve();
}
hamath