結果
| 問題 |
No.3042 拡大コピー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-28 22:51:01 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 950 bytes |
| コンパイル時間 | 21,212 ms |
| コンパイル使用メモリ | 400,868 KB |
| 実行使用メモリ | 33,168 KB |
| 最終ジャッジ日時 | 2025-03-01 07:40:36 |
| 合計ジャッジ時間 | 15,580 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 24 |
ソースコード
use proconio::input;
type Coord = (f64, f64);
const MAX_COORD: f64 = 1e9;
fn main() {
input! {
n: usize,
xy: [(f64, f64); n],
zw: [(f64, f64); n],
}
let rotated_xy = to_rotated(&xy);
let rotated_zw = to_rotated(&zw);
let max_dist_xy = calc_max_dist(&rotated_xy);
let max_dist_zw = calc_max_dist(&rotated_zw);
println!("{}", max_dist_zw - max_dist_xy);
}
fn calc_rotated_coord(coord: Coord) -> Coord {
(coord.0 - coord.1, coord.0 + coord.1)
}
fn to_rotated(coords: &[Coord]) -> Vec<Coord> {
coords.iter().cloned().map(calc_rotated_coord).collect()
}
fn calc_max_dist(coords: &[Coord]) -> f64 {
let (mut min_x, mut max_x, mut min_y, mut max_y) = (MAX_COORD, 0.0_f64, MAX_COORD, 0.0_f64);
for &(x, y) in coords {
min_x = min_x.min(x);
max_x = max_x.max(x);
min_y = min_y.min(y);
max_y = max_y.max(y);
}
max_x - min_x + max_y - min_y
}