結果

問題 No.2790 Athena 3
ユーザー atcoder8atcoder8
提出日時 2024-06-21 21:40:05
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,022 bytes
コンパイル時間 13,118 ms
コンパイル使用メモリ 401,496 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-21 21:40:20
合計ジャッジ時間 13,453 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 0 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

const DIFFS: [(f64, f64); 4] = [(1.0, 0.0), (-1.0, 0.0), (0.0, 1.0), (0.0, -1.0)];

fn main() {
    input! {
        triangle: [(f64, f64); 3],
    }

    let mut ans = 0.0;
    let mut stack: Vec<Vec<(f64, f64)>> = vec![vec![]];
    while let Some(apexes) = stack.pop() {
        if apexes.len() == 3 {
            let area = calc_area(&apexes);
            if area > ans {
                ans = area;
            }

            continue;
        }

        let apex_idx = apexes.len();
        for (dx, dy) in DIFFS {
            let mut apexes = apexes.clone();
            let (x, y) = triangle[apex_idx];
            apexes.push((x + dx, y + dy));

            stack.push(apexes);
        }
    }

    println!("{}", ans);
}

fn calc_area(triangle: &[(f64, f64)]) -> f64 {
    let (x0, y0) = triangle[0];
    let (x1, y1) = triangle[1];
    let (x2, y2) = triangle[2];

    let (dx1, dy1) = (x1 - x0, y1 - y0);
    let (dx2, dy2) = (x2 - x0, y2 - y0);

    (dx1 * dy2 - dx2 * dy1).abs() / 2.0
}
0