HDU/HDOJ 3902 Swordsman 多校联合7
来源:互联网 发布:人工智能伏羲觉醒电影 编辑:程序博客网 时间:2024/06/05 21:50
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3902
标程好像是利用后缀数组来优化计算量。
但是由于常数比较大,所以用O(n^2)也可以过掉
方法是把顶点数量扩大一倍,然后枚举对称轴即可
注意到如果i点是对称轴上的点,那么另外一个点必然是i+n
锁起来比较含糊。不过看看代码就明白了。。。我的思路也是抄别个的。。Orz。。
比赛的时候没想到。。T T
#include<stdio.h>#include<math.h>#define eps 1e-8struct point{double x;double y;};int n,m;point pt[20005];point p[40005];int Fabs(double x){if(x>eps)return 1;else if(x<-eps)return -1;elsereturn 0;}double dis(int a,int b){return sqrt((p[a].x-p[b].x)*(p[a].x-p[b].x)+(p[a].y-p[b].y)*(p[a].y-p[b].y));}bool SSS(int a,int b,int x,int y){if(Fabs(dis(a,x)-dis(b,x))==0&&Fabs(dis(a,y)-dis(b,y))==0)return true;return false;}bool check(int a,int b){int i=a,j=a;while(1){i++;j--;if(j==0)j=m;if(i==b)return true;if(!SSS(i,j,a,b))return false;}}bool judge(){int i;for(i=1;i<=m/2;i++){if(check(i,i+n))return true;}return false;}int main(){int i;while(scanf("%d",&n)!=EOF){for(i=1;i<=n;i++)scanf("%lf%lf",&pt[i].x,&pt[i].y);pt[n+1]=pt[1];m=0;for(i=1;i<=n;i++){m++;p[m]=pt[i];m++;p[m].x=(pt[i].x+pt[i+1].x)/2;p[m].y=(pt[i].y+pt[i+1].y)/2;}p[m+1]=p[1];if(judge())printf("YES\n");elseprintf("NO\n");}return 0;}
- HDU/HDOJ 3902 Swordsman 多校联合7
- hdu 3902 Swordsman
- HDU 3902 Swordsman
- HDU/HDOJ 3908 Triple 多校联合7
- HDU/HDOJ 3903 Trigonometric Function 多校联合7
- 多校联合第七场1003Swordsman(判断简单多边形是否是轴对称图形)
- hdu 3902 Swordsman 判断多边形对称
- HDOJ/HDU 3864 多校联合 D_num 数论
- HDU/HDOJ 3875 Euclidean Algorithm 多校联合第四场
- HDU/HDOJ R(N) 多校联合1
- HDU/HDOJ 3836 Equivalent Sets 多校联合1
- HDU/HDOJ 3923 2011 BJTU多校联合 波利亚原理
- HDU 3902 Swordsman 2011 Multi-University Training Contest 7 - Host by ECNU 计算几何
- Swordsman
- hdoj 4939 2014多校联合7 1005
- HDU/HDOJ 3944 DP? 多校联合11 电子科大 lucas定理
- HDU/HDOJ 3988 2011 WHU多校联合 Harry Potter and the Hide Story
- HDU/HDOJ 3519 矩阵二分幂 2010多校联合第九场
- android界面快速搭建
- Mysql wait_timeout interactive_timeout变量
- 【网上摘的】房价是怎么上去的,物价是怎么涨上去的?
- ListView保存滑动状态
- MFC tab控件的使用[zz]
- HDU/HDOJ 3902 Swordsman 多校联合7
- zoj 3131 Digital Clock
- 压缩算法
- SVN 签出源码 Struts Spring Hibernate
- ubuntu网站及数据库自动备份
- android sdcard卡操作
- vim操作图
- linux 查看文件夹目录
- 在IIS中注册ASP.NET 1.1或2.0