#!/usr/bin/env ruby # yukicoder No.55 正方形を描くだけの簡単なお仕事です。 require "matrix" EPS = 1e-8 # 原点を中心にした角angleだけの回転を表す行列を返す def rotation_matrix(angle) c = Math.cos angle s = Math.sin angle m = Matrix[[c, -s], [s, c]] return m end # 点centerを中心に角angleだけ点pointを回転したものを返す # -centerだけ平行移動 + 原点中心にangleだけ回転 + centerだけ平行移動 def rotate_around(center, point, angle) a = center + rotation_matrix(angle) * (point - center) return a end # p4を求める # 存在しなければnilを返す def find_last_point(point1, point2, point3) ps = [point1, point2, point3] ps.permutation(3) {|p1, p2, p3| q1 = rotate_around(p2, p3, Math::PI / 2.0) return rotate_around(p1, p2, Math::PI / 2.0) if (p1 - q1).r < EPS } return nil end def main() x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_i) point1 = Vector[x1, y1] point2 = Vector[x2, y2] point3 = Vector[x3, y3] ans = find_last_point(point1, point2, point3) if ans != nil puts ans.map(&:round).to_a.join(" ") else puts (-1) end end main