首先能想到的是至少有一对相邻点或者中间间隔一个点的点对满足轴对称,那么接下来只需要枚举剩下的点对是否满足至多移动一个点可以满足要求。

第一种情况,对于所有点对都满足要求,那么Yes。

第二种情况,有一个点不满足要求,那么显然这种情况只可能是奇数点的时候才出现,那么只需要将这个点移到对称轴上则满足要求,那么Yes。

第三种情况,有两个点不满足要求,然后我们需要枚举这两个点对应的对称点是否满足要求,对于其中一个点的对称点判断他是否和之前所有点重合,以及判断这个点是否在对称轴上。

这样还不够,还需要考虑对于对称轴两边的可能的对应的对称点,他们是不是在对应一侧,如果两个点都不在对应的一侧,说明这两个点自交,则不能满足要求,直接跳过。

多注意细节吧,现场wa到自闭。

数据:

  1. 5
  2. -100 -100
  3. 0 0
  4. -100 100
  5. 2 -1
  6. 100 1
  7. N
  8. 7
  9. -3 3
  10. -5 -5
  11. 1 -3
  12. -1 -3
  13. 0 2
  14. 5 -5
  15. 3 3
  16. N

附图说明:

  1. // ——By DD_BOND
  2.  
  3. //#include<bits/stdc++.h>
  4. //#include<unordered_map>
  5. //#include<unordered_set>
  6. #include<functional>
  7. #include<algorithm>
  8. #include<iostream>
  9. //#include<ext/rope>
  10. #include<iomanip>
  11. #include<climits>
  12. #include<cstring>
  13. #include<cstdlib>
  14. #include<cstddef>
  15. #include<cstdio>
  16. #include<memory>
  17. #include<vector>
  18. #include<cctype>
  19. #include<string>
  20. #include<cmath>
  21. #include<queue>
  22. #include<deque>
  23. #include<ctime>
  24. #include<stack>
  25. #include<map>
  26. #include<set>
  27.  
  28. #define fi first
  29. #define se second
  30. #define MP make_pair
  31. #define pb push_back
  32.  
  33. typedef long long ll;
  34.  
  35. using namespace std;
  36.  
  37. const int MAXN=1e3+;
  38. const double eps=1e-;
  39. const double pi=acos(-1.0);
  40. const ll INF=0x3f3f3f3f3f3f3f3f;
  41.  
  42. inline int dcmp(double x){
  43. if(fabs(x)<eps) return ;
  44. return (x>? : -);
  45. }
  46.  
  47. inline double sqr(double x){ return x*x; }
  48.  
  49. struct Point{
  50. double x,y;
  51. Point(){ x=,y=; }
  52. Point(double _x,double _y):x(_x),y(_y){}
  53. void input(){ scanf("%lf%lf",&x,&y); }
  54. bool operator ==(const Point &b)const{
  55. return (dcmp(x-b.x)==&&dcmp(y-b.y)==);
  56. }
  57. Point operator +(const Point &b)const{
  58. return Point(x+b.x,y+b.y);
  59. }
  60. Point operator -(const Point &b)const{
  61. return Point(x-b.x,y-b.y);
  62. }
  63. Point operator *(double a){
  64. return Point(x*a,y*a);
  65. }
  66. Point operator /(double a){
  67. return Point(x/a,y/a);
  68. }
  69. double len2(){ //长度平方
  70. return sqr(x)+sqr(y);
  71. }
  72. Point rotate_left(){ //逆时针旋转90度
  73. return Point(-y,x);
  74. }
  75. };
  76.  
  77. inline double cross(Point a,Point b){ //叉积
  78. return a.x*b.y-a.y*b.x;
  79. }
  80.  
  81. inline double dot(Point a,Point b){ //点积
  82. return a.x*b.x+a.y*b.y;
  83. }
  84.  
  85. struct Line{
  86. Point s,e;
  87. Line(){}
  88. Line(Point _s,Point _e):s(_s),e(_e){} //两点确定直线
  89. };
  90.  
  91. int relation(Point p,Line l){ //点和向量关系 1:左侧 2:右侧 3:在线上
  92. int c=dcmp(cross(p-l.s,l.e-l.s));
  93. if(c<) return ;
  94. else if(c>) return ;
  95. else return ;
  96. }
  97.  
  98. Point projection(Point p,Line a){ //点在直线上的投影
  99. return a.s+(((a.e-a.s)*dot(a.e-a.s,p-a.s))/(a.e-a.s).len2());
  100. }
  101.  
  102. Point symmetry(Point p,Line a){ //点关于直线的对称点
  103. Point q=projection(p,a);
  104. return Point(*q.x-p.x,*q.y-p.y);
  105. }
  106.  
  107. int vis[MAXN];
  108. vector<Line>st;
  109. Point point[MAXN];
  110.  
  111. int main(void){
  112. int T; scanf("%d",&T);
  113. while(T--){
  114. int n,ans=; scanf("%d",&n);
  115. for(int i=;i<n;i++) point[i].input();
  116. for(int i=;i<n&&!ans;i++){
  117. int s=i,t=(i+)%n;
  118. Point mid=(point[s]+point[t])/,vec=(point[s]-point[t]).rotate_left();
  119. Line line(mid,mid+vec);
  120. int num=,error=;
  121. memset(vis,,sizeof(vis));
  122. while(!vis[s]&&!vis[t]){
  123. vis[s]=,vis[t]=;
  124. Point p1=(point[s]+point[t])/,dir=(point[s]-point[t]).rotate_left();
  125. Point p2=p1+dir;
  126. if(dcmp(cross(point[i]-mid,vec))*dcmp(cross(point[s]-mid,vec))<&&dcmp(cross(point[(i+)%n]-mid,vec))*dcmp(cross(point[t]-mid,vec))<) error=;
  127. if(relation(p1,line)==&&relation(p2,line)==){
  128. if(s!=t) num+=;
  129. else num++;
  130. }
  131. s=(s-+n)%n,t=(t+)%n;
  132. }
  133. if(error) continue;
  134. if(num+>=n) ans=;
  135. else if(num+==n){
  136. s=i,t=(i+)%n;
  137. memset(vis,,sizeof(vis));
  138. while(!vis[s]&&!vis[t]){
  139. vis[s]=,vis[t]=;
  140. Point p1=(point[s]+point[t])/,vec=(point[s]-point[t]).rotate_left();
  141. Point p2=p1+vec;
  142. if(relation(p1,line)!=||relation(p2,line)!=){
  143. if(relation(point[s],line)!=&&relation(point[t],line)!=){
  144. int f1=,f2=;
  145. Point s1=symmetry(point[s],line),s2=symmetry(point[t],line);
  146. for(int j=;j<n;j++)
  147. if(point[j]==s1)
  148. f1=;
  149. for(int j=;j<n;j++)
  150. if(point[j]==s2)
  151. f2=;
  152. if(!f2||!f1) ans=;
  153. }
  154. break;
  155. }
  156. s=(s-+n)%n,t=(t+)%n;
  157. }
  158. }
  159. }
  160. for(int i=;i<n&&!ans;i++){
  161. int s=(i-+n)%n,t=(i+)%n;
  162. Point mid=(point[s]+point[t])/,vec=(point[s]-point[t]).rotate_left();
  163. Line line(mid,mid+vec);
  164. int num=,error=; s=t=i;
  165. memset(vis,,sizeof(vis));
  166. while(!vis[s]&&!vis[t]){
  167. vis[s]=,vis[t]=;
  168. Point p1=(point[s]+point[t])/,dir=(point[s]-point[t]).rotate_left();
  169. Point p2=p1+dir;
  170. if(dcmp(cross(point[(i-+n)%n]-mid,vec))*dcmp(cross(point[s]-mid,vec))<&&dcmp(cross(point[(i+)%n]-mid,vec))*dcmp(cross(point[t]-mid,vec))<) error=;
  171. if(relation(p1,line)==&&relation(p2,line)==){
  172. if(s!=t) num+=;
  173. else num++;
  174. }
  175. s=(s-+n)%n,t=(t+)%n;
  176. }
  177. if(error) continue;
  178. if(num+>=n) ans=;
  179. else if(num+==n){
  180. s=t=i;
  181. memset(vis,,sizeof(vis));
  182. while(!vis[s]&&!vis[t]){
  183. vis[s]=,vis[t]=;
  184. Point p1=(point[s]+point[t])/,vec=(point[s]-point[t]).rotate_left();
  185. Point p2=p1+vec;
  186. if(relation(p1,line)!=||relation(p2,line)!=){
  187. if(relation(point[s],line)!=&&relation(point[t],line)!=){
  188. int f1=,f2=;
  189. Point s1=symmetry(point[s],line),s2=symmetry(point[t],line);
  190. for(int j=;j<n;j++)
  191. if(point[j]==s1)
  192. f1=;
  193. for(int j=;j<n;j++)
  194. if(point[j]==s2)
  195. f2=;
  196. if(!f2||!f1) ans=;
  197. }
  198. break;
  199. }
  200. s=(s-+n)%n,t=(t+)%n;
  201. }
  202. }
  203. }
  204. if(ans) puts("Y");
  205. else puts("N");
  206. }
  207. return ;
  208. }

HDU 6631 line symmetric(枚举)的更多相关文章

  1. HDU 6631 line symmetric 计算几何

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6631 题意:共\(T\)组数据,每组数据给出\(n\)个点的坐标,这\(n\)个点按顺序给出,相邻的点 ...

  2. HDU 3400 Line belt (三分再三分)

    HDU 3400 Line belt (三分再三分) ACM 题目地址:  pid=3400" target="_blank" style="color:rgb ...

  3. HDU 5778 abs (枚举)

    abs 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5778 Description Given a number x, ask positive ...

  4. 三分套三分 --- HDU 3400 Line belt

    Line belt Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=3400 Mean: 给出两条平行的线段AB, CD,然后一 ...

  5. HDU 3835 R(N)(枚举)

    题目链接 Problem Description We know that some positive integer x can be expressed as x=A^2+B^2(A,B are ...

  6. HDU 4709 Herding (枚举)

    Herding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  7. HDU 4462Scaring the Birds(枚举所有状态)

    Scaring the Birds Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  8. 2015多校第6场 HDU 5358 First One 枚举,双指针

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5358 题意:如题. 解法:观察式子发现,由于log函数的存在,使得这个函数的值域<=34,然后我 ...

  9. HDU 4431 Mahjong(枚举+模拟)(2012 Asia Tianjin Regional Contest)

    Problem Description Japanese Mahjong is a four-player game. The game needs four people to sit around ...

随机推荐

  1. Springboot配置文件占位符

    一.配置文件占位符 1.application.properties server.port=8088 debug=false product.id=ID:${random.uuid} product ...

  2. 与Swing的相识

    参考自http://c.biancheng.net/swing/ Swing是一个用于Java GUI编程(图形界面设计)的工具包(类库):换句话说,java可以用来开发带界面的PC软件,使用到的工具 ...

  3. ESP8266的使用学习

     ESP8266-01  ESP8266-12F简介 让灯闪烁    ESP8266-中断   模拟输入(ADC-A0)  模拟输出(PWM)  串口通信(Serial)    EEPROM类库的使用 ...

  4. Alter改变终结

    #alter#删除date列但若表中只有一个字段无法使用drop删除ALTER TABLE z_staff_info_copy1 DROP `date`;ALTER TABLE z_staff_inf ...

  5. echart--如何将echart的配置项,放到webpack中(CHARTTEMPLATE时)

    1.假如,我们已经写好了组件,我们需要把它放入到一个环境中去 2.首先在index.html中,我们需要写一个dom结构 3.新建一个,chart.js文件(这个里面放组件的代码) 1>开始创建 ...

  6. tweenMax+如何让数字由初始值动画到结束的值

    html: <div class="wz1">0</div> css: .wz1{ width: 114px; height: 30px; position ...

  7. 3,ActiveMQ-入门(基于JMS发布订阅模型)

    一.Pub/Sub-发布/订阅消息传递模型 在发布/订阅消息模型中,发布者发布一个消息,该消息通过topic传递给所有的客户端.在这种模型中,发布者和订阅者彼此不知道对方,是匿名的且可以动态发布和订阅 ...

  8. 12 Spring Boot密码加密算法

  9. Vue框架基础概要

    Vue.js是什么? Vue.js(读音 /vjuː/,类似于 view 的读音)是一套构建用户界面(user interface)的渐进式框架.与其他重量级框架不同的是,Vue 从根本上采用最小成本 ...

  10. WEB实现大文件上传和下载

    我们平时经常做的是上传文件,上传文件夹与上传文件类似,但也有一些不同之处,这次做了上传文件夹就记录下以备后用. 这次项目的需求: 支持大文件的上传和续传,要求续传支持所有浏览器,包括ie6,ie7,i ...