1. Put a piece of wood block on the desk, and then suddenly wave the sword, cutting the block into two pieces.
2. Without any motion, the two pieces must be absolutely axial symmetry.
According to the step two, when the board is an axial symmetry figure, Mr. AC has a chance to achieve the “Perfect Cut”. Now give you a board, and you should tell if Mr. AC has a chance to complete the “Perfect Cut”. The board is a simple polygon.
The first line of one case contains a single integer n (3 <= n <= 20000), the number of points. The next n lines indicate the points of the simple polygon, each line with two integers x, y (0 <= x, y <= 20000). The points would be given either clockwise or counterclockwise.
3 0 0 2 0 0 1 4 0 0 0 1 1 1 1 0
NO YES
//就算对称轴的个数
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cmath>
#include<cstdio>
using namespace std;
const int maxn=20010;
int N,M,Tot,next[maxn];
int x[maxn],y[maxn];
long long ans;
struct Point
{
long long ed,ag;
}P[2*maxn],Q[maxn];
bool operator==(Point A,Point B)
{
return A.ed==B.ed&&A.ag==B.ag;
}
void scanInt(int &x)
{
char ch;
while(ch=getchar(),ch<'0'||ch>'9');
x=ch-'0';
while(ch=getchar(),ch>='0'&&ch<='9')x*=10,x+=ch-'0';
}
void FindNext()
{
next[0]=-1;
next[1]=0;
for(int i=2;i<N;++i)
{
int p=next[i-1];
for(;!(Q[p]==Q[i-1])&&p;)

本文提供两种不同的算法实现,用于判断一个给定的多边形是否轴对称以及对称轴的个数。第一种是基于向量运算的O(n^2)复杂度算法,第二种是利用后缀数组和最小高度的O(nlog(n))复杂度算法。这两种方法均能有效地确定多边形的对称性。
最低0.47元/天 解锁文章
1044

被折叠的 条评论
为什么被折叠?



