136. Erasing Edges

time limit per test: 0.25 sec. 
memory limit per test: 4096 KB

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.

Input

The first line of the input contains the integer number N (3<=N<=10 000). Then, N lines will follow, each of them containing real numbers, separated by blanks: xi and yi(xi,yi) are the coordinates of the middle point of the edge #i. The coordinates will be given with at most 3 decimal places.

Output

Print a line containing the word "YES", if the polygon can be redrawn, or "NO", if there exists no polygon having the given coordinates for the middle points of its edges. If the answer is "YES", then you should print N more lines, each of them containing two real numbers, separated by a blank, representing the X and Y coordinates of the vetices of the polygon. The coordinates should be printed with at least 3decimal places. You should output the cordinates for vertex #1 first, for vertex #2 second and so on.. In order to decide which vertex of the polygon is #1,#2,..,#N, you should know that for every 1<=i<=N-1, edge #i connects the vertices labeled i and i+1. Edge #N connects the vertices N and 1.

Hint

The polygon may contain self-intersections. Although in many geometric problems, self-intersections only make things more difficult, in this case, they make things a lot easier.

Sample Input #1

4
0 0
2 0
2 2
0 2

Sample Output #1

YES
-1.000 1.000
1.000 -1.000
3.000 1.000
1.000 3.000

Sample Input #2

4
0 0
2 0
2 2
1 3

Sample Output #2

NO
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
struct pnt{
double x,y;
};
const int maxn=10001;
const double eps=1e-9;
pnt p[maxn];
int n;
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%lf%lf",&p[i].x,&p[i].y);
}
double lvaluex=0,lvaluey=0;
int cnt=1;
for(int i=n-1;i>0;i--){
lvaluex+=cnt?p[i].x:-p[i].x;
lvaluey+=cnt?p[i].y:-p[i].y;
cnt^=1;
}
if((n&1)==0&&n>2&&(fabs(lvaluex-p[0].x)>eps||fabs(lvaluey-p[0].y)>eps)){puts("NO");return 0;}
puts("YES");
double x=(p[0].x+lvaluex);
double y=(p[0].y+lvaluey);
for(int i=0;i<n;i++){
printf("%.3f %.3f\n",x,y);
x=p[i].x*2-x;
y=p[i].y*2-y;
}
return 0;
}

  

快速切题 sgu136. Erasing Edges的更多相关文章

  1. 快速切题 sgu134.Centroid 树形dp

    134. Centroid time limit per test: 0.25 sec. memory limit per test: 4096 KB You are given an undirec ...

  2. Erasing Edges - SGU 136(构造多边形)

    题目大意:已知一个多边形上的每条边的中点,还原出来一个多边形. 分析:因为偶数是不固定的,所以可以为任意起点,奇数只有一个,可以所有中点加减算出来第一个点,然后就是简单的向量计算点的位置了...... ...

  3. 快速切题sgu127. Telephone directory

    127. Telephone directory time limit per test: 0.25 sec. memory limit per test: 4096 KB CIA has decid ...

  4. 快速切题sgu126. Boxes

    126. Boxes time limit per test: 0.25 sec. memory limit per test: 4096 KB There are two boxes. There ...

  5. 快速切题 sgu123. The sum

    123. The sum time limit per test: 0.25 sec. memory limit per test: 4096 KB The Fibonacci sequence of ...

  6. 快速切题 sgu120. Archipelago 计算几何

    120. Archipelago time limit per test: 0.25 sec. memory limit per test: 4096 KB Archipelago Ber-Islan ...

  7. 快速切题 sgu119. Magic Pairs

    119. Magic Pairs time limit per test: 0.5 sec. memory limit per test: 4096 KB “Prove that for any in ...

  8. 快速切题 sgu118. Digital Root 秦九韶公式

    118. Digital Root time limit per test: 0.25 sec. memory limit per test: 4096 KB Let f(n) be a sum of ...

  9. 快速切题 sgu117. Counting 分解质因数

    117. Counting time limit per test: 0.25 sec. memory limit per test: 4096 KB Find amount of numbers f ...

随机推荐

  1. inotify+rsync安装配置

    环境 系统 IP地址 主服务器 CentOS7.4 192.168.1.1 备份服务器 CentOS7.4 192.168.1.2 一.备份服务器 安装rsync(备) wget https://rs ...

  2. 七夕节---hdu1215(打表求因子和)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1215 给你一个数n(1<=n<=50w)求n的所有因子和, 由于n的范围比较大,所以要采用 ...

  3. saltstack master minion 配置文件

    Master端的配置是修改/etc/salt下master配置文件.以下是Master端常用的配置. interface: 指定bind 的地址(默认为0.0.0.0) publish_port: 指 ...

  4. 【转】Deep Learning(深度学习)学习笔记整理系列之(二)

    因为我们要学习的是特征的表达,那么关于特征,或者说关于这个层级特征,我们需要了解地更深入点.所以在说Deep Learning之前,我们有必要再啰嗦下特征(呵呵,实际上是看到那么好的对特征的解释,不放 ...

  5. 解决maven的依赖总是无法下载完成

    有时候在eclipse里面刚刚导进一个maven项目,但是总是无法完整下载pom文件里面的依赖 主要有两个原因: 1,需要下载的依赖(jar包)需要开发人员给权限(远程仓库的下载权限),这个可以找开发 ...

  6. 本地blast的安装

    1 下载程序 在ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/下载 ncbi-blast-2.2.25+-x64-linux.t ...

  7. cocos代码研究(26)Widget子类RichView学习笔记

    理论部分 一个显示多个RichElement的容器类. 我们可以使用它很容易显示带图片的文本,继承自 Widget. 代码实践 static RichText * create ()创建一个空的Ric ...

  8. html5 七巧板

    <!DOCTYPE html><html>    <canvas id="diag" height="200" width=&qu ...

  9. Python笔记 #04# Methods

    源:DataCamp datacamp 的 DAILY PRACTICE  + 日常收集. Methods String Methods List Methods 缺一 Methods You can ...

  10. loj2163 / bzoj2212 / P3521 [POI2011]ROT-Tree Rotations(线段树合并)

    P3521 [POI2011]ROT-Tree Rotations loj2163 [POI2011]ROT-Tree Rotations(数据加强) (loj的数据套了个fread优化才过...) ...