#[allow(unused)] use proconio::{input, marker::Chars}; fn main() { input! { xy: [(i32, i32); 3], } for i in 0..3 { for j in 0..3 { if i != j { for k in 0..3 { if i != k && j != k { let (ax, ay) = xy[i]; let (bx, by) = xy[j]; let (cx, cy) = xy[k]; let dx = ax + cx - bx; let dy = ay + cy - by; if let Ok((x, y)) = is_square(xy[i], xy[j], xy[k], (dx, dy)) { println!("{} {}", x, y); return; } } } } } } println!("-1") } fn is_square( a: (i32, i32), b: (i32, i32), c: (i32, i32), d: (i32, i32), ) -> Result<(i32, i32), i32> { if distance(a, b) == distance(b, c) && distance(b, c) == distance(c, d) && distance(c, d) == distance(a, b) { if distance(a, c) == distance(b, d) { if distance(a, b) > 0 { return Ok(d); } } } Err(-1) } fn distance(a: (i32, i32), b: (i32, i32)) -> i32 { (a.0 - b.0).abs() + (a.1 - b.1).abs() }