Little Johnny painted on a sheet of paper a polygon with $N$ vertices. Then, for every edge of the polygon, he drew the middle point of the edge. After that, he went to school. When he came back, he found out that his brother had erased the polygon (both the edges and the vertices). The only thing left were the middle points of the edges of the polygon. Help Johnny redraw his polygon.
staticconstdouble EPS = 1e-6; intcmp(double a, double b){ returnfabs(a - b) < EPS ? 0 : a < b ? -1 : 1; }
structPoint { double x, y; Point(double _x = 0, double _y = 0) : x(_x), y(_y) {} Point operator + (const Point &p) const { returnPoint(x + p.x, y + p.y); } Point operator - (const Point &p) const { returnPoint(x - p.x, y - p.y); } Point operator * (constdouble &n) const { returnPoint(x * n, y * n); } Point operator / (constdouble &n) const { return *this * (1 / n); } Point operator | (const Point &p) const { return *this + (p - *this) * 2; } };
structSolver { private: staticconstint N = 10010; int n; Point point[N]; vector <Point> ans; voidinput(){ scanf("%d", &n); for (int i = 1; i <= n; ++ i) scanf("%lf%lf", &point[i].x, &point[i].y); } voidprocess(){ Point p; if (n & 1) { double sum = 0; for (int i = 1; i <= n; ++ i) sum += point[i].x; for (int i = 2; i <= n; i += 2) sum -= point[i].x * 2; p.x = sum, sum = 0; for (int i = 1; i <= n; ++ i) sum += point[i].y; for (int i = 2; i <= n; i += 2) sum -= point[i].y * 2; p.y = sum; } else p = Point(random * 100000, random * 100000); for (int i = 1; i <= n; ++ i) ans.push_back(p), p = p | point[i]; if (cmp(p.x, ans[0].x) || cmp(p.y, ans[0].y)) printf("NO\n"); else { printf("YES\n"); for (int i = 0; i < ans.size(); ++ i) printf("%.6lf %.6lf\n", ans[i].x, ans[i].y); } }