結果

問題 No.2790 Athena 3
ユーザー Tatsu_mr
提出日時 2024-06-21 21:42:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,774 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 196,492 KB
最終ジャッジ日時 2025-02-21 23:53:22
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ld = long double;
using P = pair<ld, ld>;

int main() {
    ld x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    P a = {x1, y1}, b = {x2, y2}, c = {x3, y3};
    
    auto f0 = [](P p) -> P { return {p.first + 1, p.second}; };
    auto f1 = [](P p) -> P { return {p.first - 1, p.second}; };
    auto f2 = [](P p) -> P { return {p.first, p.second + 1}; };
    auto f3 = [](P p) -> P { return {p.first, p.second - 1}; };
    
    auto s = [](P a, P b, P c) -> ld {
        ld xb = b.first - a.first, yb = b.second - a.second;
        ld xc = c.first - a.first, yc = c.second - a.second;
        return abs(xb * yc - xc * yb) / 2;
    };
    
    ld ans = 0;
    
    for (int i = 0; i < 4; i++) {
        P na;
        if (i == 0) {
            na = f0(a);
        } else if (i == 1) {
            na = f1(a);
        } else if (i == 2) {
            na = f2(a);
        } else {
            na = f3(a);
        }
        for (int j = 0; j < 4; j++) {
            P nb;
            if (j == 0) {
                nb = f0(b);
            } else if (j == 1) {
                nb = f1(b);
            } else if (j == 2) {
                nb = f2(b);
            } else {
                nb = f3(b);
            }
            for (int k = 0; k < 4; k++) {
                P nc;
                if (k == 0) {
                    nc = f0(c);
                } else if (k == 1) {
                    nc = f1(c);
                } else if (k == 2) {
                    nc = f2(c);
                } else {
                    nc = f3(c);
                }
                
                ans = max(ans, s(na, nb, nc));
            }
        }
    }
    
    cout << fixed << setprecision(1) << ans << endl;
}
0