import std.algorithm, std.array, std.container, std.range; import std.string, std.conv, std.math; import std.stdio, std.typecons; alias Tuple!(int, "x", int, "y") point; void main() { auto rd = readln.split.map!(to!int); auto p1 = point(rd[0], rd[1]); auto p2 = point(rd[2], rd[3]); auto p3 = point(rd[4], rd[5]); auto r = call(p1, p2, p3); if (r.isNull) writeln(-1); else writeln(r.x, " ", r.y); } Nullable!point call(point p1, point p2, point p3) { foreach (ps; [tuple(p1, p2, p3), tuple(p2, p3, p1), tuple(p3, p1, p2)]) { auto r = calc(ps.expand); if (!r.isNull) return r; } return Nullable!point.init; } Nullable!point calc(point p1, point p2, point p3) { auto v12 = point(p1.x - p2.x, p1.y - p2.y); auto v23 = point(p2.x - p3.x, p2.y - p3.y); if (vabs(v12) == vabs(v23) && vinner_prod(v12, v23) == 0) { auto pc = point((p1.x + p3.x) / 2, (p1.y + p3.y) / 2); return Nullable!point(point(p1.x + p3.x - p2.x, p1.y + p3.y - p2.y)); } else { return Nullable!point.init; } } int vabs(point v) { return v.x ^^ 2 + v.y ^^ 2; } int vinner_prod(point v1, point v2) { return v1.x * v2.x + v1.y * v2.y; }