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

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

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

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

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

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

数据:

5
-100 -100
0 0
-100 100
2 -1
100 1
N 7
-3 3
-5 -5
1 -3
-1 -3
0 2
5 -5
3 3
N

附图说明:

 //        ——By DD_BOND

 //#include<bits/stdc++.h>
//#include<unordered_map>
//#include<unordered_set>
#include<functional>
#include<algorithm>
#include<iostream>
//#include<ext/rope>
#include<iomanip>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<cstddef>
#include<cstdio>
#include<memory>
#include<vector>
#include<cctype>
#include<string>
#include<cmath>
#include<queue>
#include<deque>
#include<ctime>
#include<stack>
#include<map>
#include<set> #define fi first
#define se second
#define MP make_pair
#define pb push_back typedef long long ll; using namespace std; const int MAXN=1e3+;
const double eps=1e-;
const double pi=acos(-1.0);
const ll INF=0x3f3f3f3f3f3f3f3f; inline int dcmp(double x){
if(fabs(x)<eps) return ;
return (x>? : -);
} inline double sqr(double x){ return x*x; } struct Point{
double x,y;
Point(){ x=,y=; }
Point(double _x,double _y):x(_x),y(_y){}
void input(){ scanf("%lf%lf",&x,&y); }
bool operator ==(const Point &b)const{
return (dcmp(x-b.x)==&&dcmp(y-b.y)==);
}
Point operator +(const Point &b)const{
return Point(x+b.x,y+b.y);
}
Point operator -(const Point &b)const{
return Point(x-b.x,y-b.y);
}
Point operator *(double a){
return Point(x*a,y*a);
}
Point operator /(double a){
return Point(x/a,y/a);
}
double len2(){ //长度平方
return sqr(x)+sqr(y);
}
Point rotate_left(){ //逆时针旋转90度
return Point(-y,x);
}
}; inline double cross(Point a,Point b){ //叉积
return a.x*b.y-a.y*b.x;
} inline double dot(Point a,Point b){ //点积
return a.x*b.x+a.y*b.y;
} struct Line{
Point s,e;
Line(){}
Line(Point _s,Point _e):s(_s),e(_e){} //两点确定直线
}; int relation(Point p,Line l){ //点和向量关系 1:左侧 2:右侧 3:在线上
int c=dcmp(cross(p-l.s,l.e-l.s));
if(c<) return ;
else if(c>) return ;
else return ;
} Point projection(Point p,Line a){ //点在直线上的投影
return a.s+(((a.e-a.s)*dot(a.e-a.s,p-a.s))/(a.e-a.s).len2());
} Point symmetry(Point p,Line a){ //点关于直线的对称点
Point q=projection(p,a);
return Point(*q.x-p.x,*q.y-p.y);
} int vis[MAXN];
vector<Line>st;
Point point[MAXN]; int main(void){
int T; scanf("%d",&T);
while(T--){
int n,ans=; scanf("%d",&n);
for(int i=;i<n;i++) point[i].input();
for(int i=;i<n&&!ans;i++){
int s=i,t=(i+)%n;
Point mid=(point[s]+point[t])/,vec=(point[s]-point[t]).rotate_left();
Line line(mid,mid+vec);
int num=,error=;
memset(vis,,sizeof(vis));
while(!vis[s]&&!vis[t]){
vis[s]=,vis[t]=;
Point p1=(point[s]+point[t])/,dir=(point[s]-point[t]).rotate_left();
Point p2=p1+dir;
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=;
if(relation(p1,line)==&&relation(p2,line)==){
if(s!=t) num+=;
else num++;
}
s=(s-+n)%n,t=(t+)%n;
}
if(error) continue;
if(num+>=n) ans=;
else if(num+==n){
s=i,t=(i+)%n;
memset(vis,,sizeof(vis));
while(!vis[s]&&!vis[t]){
vis[s]=,vis[t]=;
Point p1=(point[s]+point[t])/,vec=(point[s]-point[t]).rotate_left();
Point p2=p1+vec;
if(relation(p1,line)!=||relation(p2,line)!=){
if(relation(point[s],line)!=&&relation(point[t],line)!=){
int f1=,f2=;
Point s1=symmetry(point[s],line),s2=symmetry(point[t],line);
for(int j=;j<n;j++)
if(point[j]==s1)
f1=;
for(int j=;j<n;j++)
if(point[j]==s2)
f2=;
if(!f2||!f1) ans=;
}
break;
}
s=(s-+n)%n,t=(t+)%n;
}
}
}
for(int i=;i<n&&!ans;i++){
int s=(i-+n)%n,t=(i+)%n;
Point mid=(point[s]+point[t])/,vec=(point[s]-point[t]).rotate_left();
Line line(mid,mid+vec);
int num=,error=; s=t=i;
memset(vis,,sizeof(vis));
while(!vis[s]&&!vis[t]){
vis[s]=,vis[t]=;
Point p1=(point[s]+point[t])/,dir=(point[s]-point[t]).rotate_left();
Point p2=p1+dir;
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=;
if(relation(p1,line)==&&relation(p2,line)==){
if(s!=t) num+=;
else num++;
}
s=(s-+n)%n,t=(t+)%n;
}
if(error) continue;
if(num+>=n) ans=;
else if(num+==n){
s=t=i;
memset(vis,,sizeof(vis));
while(!vis[s]&&!vis[t]){
vis[s]=,vis[t]=;
Point p1=(point[s]+point[t])/,vec=(point[s]-point[t]).rotate_left();
Point p2=p1+vec;
if(relation(p1,line)!=||relation(p2,line)!=){
if(relation(point[s],line)!=&&relation(point[t],line)!=){
int f1=,f2=;
Point s1=symmetry(point[s],line),s2=symmetry(point[t],line);
for(int j=;j<n;j++)
if(point[j]==s1)
f1=;
for(int j=;j<n;j++)
if(point[j]==s2)
f2=;
if(!f2||!f1) ans=;
}
break;
}
s=(s-+n)%n,t=(t+)%n;
}
}
}
if(ans) puts("Y");
else puts("N");
}
return ;
}

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. docker常用命令及操作

    1).镜像操作 操作 命令 说明 检索 docker search 关 键 字 eg:docker search redis 我们经常去docker hub上检索镜像的详细信息,如镜像的TAG. 拉取 ...

  2. hashcode 和 equals

    https://www.cnblogs.com/Qian123/p/5703507.html#_label0 hashCode是jdk根据对象的地址或者字符串或者数字算出来的int类型的数值 详细了解 ...

  3. Flask【第3篇】:蓝图、基于DBUtils实现数据库连接池、上下文管理等

    基于DBUtils实现数据库连接池 小知识: 1.子类继承父类的三种方式 class Dog(Animal): #子类 派生类 def __init__(self,name,breed, life_v ...

  4. XNUCA 2019ezPHP

    ezPHP 源码很简单(感觉越简单的源码越不好搞),一个写文件的功能且只能写文件名为[a-z.]* 的文件,且文件内容存在黑名单过滤,并且结尾被加上了一行,这就导致我们无法直接写入.htaccess里 ...

  5. C++ GUI Qt4学习笔记03

    C++ GUI Qt4学习笔记03   qtc++spreadsheet文档工具resources 本章介绍创建Spreadsheet应用程序的主窗口 1.子类化QMainWindow 通过子类化QM ...

  6. 【Luogu4191】[CTSC2010] 性能优化

    题目链接 题意简述 求循环卷积意义下的 \(A(x)*B(x)^C\). 模数为 n+1 ,长度为 n. Sol 板子题. 循环卷积可直接把点值快速幂来解决. 所以问题就是要快速 \(DFT\),由于 ...

  7. springboot2.0+mysql整合mybatis,发现查询出来的时间比数据库datetime值快了8小时

    参考:https://blog.csdn.net/lx12345_/article/details/82020858 修改后查询数据正常

  8. asp.net 怎么上传文件夹啊,不传压缩包

    最近遇见一个需要上传百兆大文件的需求,调研了七牛和腾讯云的切片分段上传功能,因此在此整理前端大文件上传相关功能的实现. 在某些业务中,大文件上传是一个比较重要的交互场景,如上传入库比较大的Excel表 ...

  9. 洛谷P1309 瑞士轮——题解

    题目传送 思路非常简单,只要开始时把结构体排个序,每次给赢的加分再排序,共r次,最后再输出分数第q大的就行了. (天真的我估错时间复杂度用每次用sort暴力排序结果60分...)实际上这道题估算时间复 ...

  10. 使用xshell远程连接Linux

    Linux系统对于程序员来说并不陌生,对IT技术员来说是一个很好的开发平台,因此掌握Linux系统的操作对于一个程序员来说非常有用.而对于习惯使用windows的人来说直接在Linux系统下进行操作感 ...