結果
問題 | No.2790 Athena 3 |
ユーザー |
|
提出日時 | 2024-06-21 21:40:05 |
言語 | Rust (1.83.0 + proconio) |
結果 |
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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
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}