結果

問題 No.2331 Maximum Quadrilateral
ユーザー hiikunZhiikunZ
提出日時 2023-05-28 15:01:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,524 ms / 2,000 ms
コード長 2,153 bytes
コンパイル時間 4,989 ms
コンパイル使用メモリ 266,888 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 11:14:49
合計ジャッジ時間 30,732 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,340 ms
4,380 KB
testcase_01 AC 787 ms
4,376 KB
testcase_02 AC 959 ms
4,380 KB
testcase_03 AC 961 ms
4,376 KB
testcase_04 AC 1,251 ms
4,380 KB
testcase_05 AC 1,329 ms
4,376 KB
testcase_06 AC 1,242 ms
4,380 KB
testcase_07 AC 1,106 ms
4,376 KB
testcase_08 AC 764 ms
4,380 KB
testcase_09 AC 704 ms
4,376 KB
testcase_10 AC 640 ms
4,376 KB
testcase_11 AC 692 ms
4,376 KB
testcase_12 AC 633 ms
4,376 KB
testcase_13 AC 678 ms
4,380 KB
testcase_14 AC 1,390 ms
4,380 KB
testcase_15 AC 93 ms
4,376 KB
testcase_16 AC 442 ms
4,376 KB
testcase_17 AC 22 ms
4,376 KB
testcase_18 AC 118 ms
4,376 KB
testcase_19 AC 31 ms
4,380 KB
testcase_20 AC 1,522 ms
4,376 KB
testcase_21 AC 1,524 ms
4,380 KB
testcase_22 AC 1,516 ms
4,376 KB
testcase_23 AC 1,521 ms
4,376 KB
testcase_24 AC 1,513 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,384 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<atcoder/convolution>

using namespace std;
using namespace atcoder;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
ll MOD = 998244353;
ll MAX = 1e18;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    vector<ll> X(N),Y(N);
    for(ll i = 0;i < N;i++){
        cin >> X[i] >> Y[i];
    }
    ll ans = 0;
    for(ll ii = 0;ii < N;ii++){
        for(ll jj = ii + 1;jj < N;jj++){
            ll i = ii,j = jj;
            ll dx = X[i] - X[j];
            ll dy = Y[i] - Y[j];
            if(dy < 0){
                i = jj;
                j = ii;
                dx = X[i] - X[j];
                dy = Y[i] - Y[j];
            }
            vector<ll> A,B;
            if(dy == 0){
                for(ll k = 0;k < N;k++){
                    if(k == i || k == j) continue;
                    ll a = abs(X[j] - X[i]);
                    ll c = a * abs(Y[k] - Y[i]);
                    if(Y[k] > Y[i]){
                        A.push_back(c);
                    }
                    else{
                        B.push_back(c);
                    }
                }
            }
            else{
                for(ll k = 0;k < N;k++){
                    if(k == i || k == j) continue;
                    ll a1 = X[k] - X[i],b1 = Y[k] - Y[i],a2 = X[j] - X[i],b2 = Y[j] - Y[i];
                    ll c = a1 * b2 - b1 * a2;
                    if(c < 0) c = -c;
                    if((dy) * (X[k] - X[i]) + Y[i] * dx < Y[k] * dx){
                        A.push_back(c);
                    }
                    else{
                        B.push_back(c);
                    }
                }
            }
            sort(A.begin(),A.end());
            sort(B.begin(),B.end());
            if(!A.empty()) ans = max(ans,A.back() - A.front());
            if(!B.empty())ans = max(ans,B.back() - B.front());
            if(!A.empty() && !B.empty()) ans = max(ans,B.back() + A.back());
        }
    }
    cout << ans << endl;
}
0