結果

問題 No.2331 Maximum Quadrilateral
ユーザー umimelumimel
提出日時 2023-05-28 15:39:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,662 bytes
コンパイル時間 1,755 ms
コンパイル使用メモリ 168,232 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-27 12:38:36
合計ジャッジ時間 4,315 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 WA -
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 WA -
testcase_37 AC 2 ms
4,380 KB
testcase_38 WA -
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1 ms
4,380 KB
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const ll MOD1000000007 = 1000000007;
const ll MOD998244353 = 998244353;
const ll MOD[3] = {999727999, 1070777777, 1000000007};
const ll LINF = 1LL << 60;
const int IINF = 1 << 30 - 1;

template<typename T> struct Edge{
    int to; T w;
    Edge(int to_, T w_=1){
        to = to_;
        w=w_;
    }
};
template<typename T> using Tree = vector<vector<Edge<T>>>;
template<typename T> using Graph = vector<vector<Edge<T>>>;
/* 容量&重み付きエッジ for Dinic */
template<typename T> struct REdge{
    int to;
    T cap;
    T cost;
    int rev;
    REdge(int to_, T cap_, T cost_=1){
        to = to_;
        cap = cap_;
        cost = cost_;
    }
    
    REdge(int to_, T cap_, T cost_, int rev_){
        to = to_;
        cap = cap_;
        cost = cost_;
        rev = rev_;
    }
};

/* 残余グラフ for Dinic */
template<typename T> using RGraph = vector<vector<REdge<T>>>;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    vector<pll> p(n);
    rep(i, n) cin >> p[i].fi >> p[i].se;

    //下側凸包
    vector<pll> qs(2*n);
    ll k = 0;
    rep(i, n){
        if(k>1){
            while(true){
                pll q1 = {qs[k-1].fi-qs[k-2].fi, qs[k-1].se-qs[k-2].se};
                pll q2 = {p[i].fi-qs[k-1].fi, p[i].se-qs[k-1].se};
                if(q1.fi*q2.se-q1.se*q2.fi <= 0) k--;
                else break;
                if(k<=1) break;
            }
        }
        qs[k++] = p[i];
    }
 
    //上側凸包
    for(ll i=n-2, t=k; i>=0; i--){
        if(k>t){
            while(true){
                pll q1 = {qs[k-1].fi-qs[k-2].fi, qs[k-1].se-qs[k-2].se};
                pll q2 = {p[i].fi-qs[k-1].fi, p[i].se-qs[k-1].se};
                if(q1.fi*q2.se-q1.se*q2.fi <= 0) k--;
                else break;
                if(k==t) break;
            }
        }
        qs[k++] = p[i];
    }
    
    ll ans = 0;
    for(ll a=0; a<k-3; a++) for(ll b=a+1; b<k-2; b++) for(ll c=b+1; b<k-1; b++) for(ll d=c+1; c<k; c++){
        ll sa = 0;
        sa += (qs[a].fi-qs[b].fi)*(qs[a].se+qs[b].se);
        sa += (qs[b].fi-qs[c].fi)*(qs[b].se+qs[c].se);
        sa += (qs[c].fi-qs[d].fi)*(qs[c].se+qs[d].se);
        sa += (qs[d].fi-qs[a].fi)*(qs[d].se+qs[a].se);
        ans = max(ans, abs(sa));
    }

    cout << ans << endl;
}
0