2015ACM/ICPC亚洲区长春站 G hdu 5533 Dancing Stars on Me
Dancing Stars on Me
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 186 Accepted Submission(s): 124
Formally, a regular polygon is a convex polygon whose angles are all equal and all its sides have the same length. The area of a regular polygon must be nonzero. We say the stars can form a regular polygon if they are exactly the vertices of some regular polygon. To simplify the problem, we project the sky to a two-dimensional plane here, and you just need to check whether the stars can form a regular polygon in this plane.
1≤T≤300
3≤n≤100
−10000≤xi,yi≤10000
All coordinates are distinct.
3
0 0
1 1
1 0
4
0 0
0 1
1 0
1 1
5
0 0
0 1
0 2
2 2
2 0
YES
NO
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define MLL (1000000000000000001LL)
#define INF (1000000001)
#define For(i, s, t) for(int i = (s); i <= (t); i ++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i --)
#define Rep(i, n) for(int i = (0); i < (n); i ++)
#define Repn(i, n) for(int i = (n)-1; i >= (0); i --)
#define mk make_pair
#define ft first
#define sd second
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define sz(x) ((int) (x).size())
inline void SetIO(string Name)
{
string Input = Name + ".in";
string Output = Name + ".out";
freopen(Input.c_str(), "r", stdin);
freopen(Output.c_str(), "w", stdout);
} inline int Getint()
{
char ch = ' ';
int Ret = ;
bool Flag = ;
while(!(ch >= '' && ch <= ''))
{
if(ch == '-') Flag ^= ;
ch = getchar();
}
while(ch >= '' && ch <= '')
{
Ret = Ret * + ch - '';
ch = getchar();
}
return Flag ? -Ret : Ret;
} const int N = ;
struct Point
{
int x, y;
} Arr[N];
int n; inline void Solve(); inline void Input()
{
int TestNumber = Getint();
while(TestNumber--)
{
n = Getint();
For(i, , n)
{
Arr[i].x = Getint();
Arr[i].y = Getint();
}
Solve();
}
} inline LL Sqr(int x) {
return 1LL * x * x;
} inline int Multi(const Point &O, const Point &A, const Point &B)
{
int X1 = A.x - O.x, X2 = B.x - O.x, Y1 = A.y - O.y, Y2 = B.y - O.y;
return X1 * Y2 - X2 * Y1;
} inline LL GetDist(const Point &A, const Point &B)
{
return Sqr(B.x - A.x) + Sqr(B.y - A.y);
} inline bool Compare(const Point &A, const Point &B)
{
int Det = Multi(Arr[], A, B);
if(Det) return Det > ;
LL Dist1 = GetDist(Arr[], A), Dist2 = GetDist(Arr[], B);
return Dist1 < Dist2;
} inline void Solve()
{
For(i, , n)
if(Arr[i].x < Arr[].x || (Arr[i].x == Arr[].x && Arr[i].y < Arr[].y))
swap(Arr[i], Arr[]);
sort(Arr + , Arr + + n, Compare); Arr[n + ] = Arr[], Arr[n + ] = Arr[];
bool Flag = ;
int Tmp, Dist;
For(i, , n)
{
int Det = Multi(Arr[i], Arr[i + ], Arr[i + ]);
LL Dist1 = GetDist(Arr[i], Arr[i + ]);
LL Dist2 = GetDist(Arr[i + ], Arr[i + ]);
if(Det <= || Dist1 != Dist2)
{
puts("NO");
return ;
}
if(Flag)
{
if(Tmp != Det || Dist1 != Dist)
{
puts("NO");
return ;
}
}
else Flag = , Tmp = Det, Dist = Dist1;
}
puts("YES");
} int main()
{
Input();
//Solve();
return ;
}
2015ACM/ICPC亚洲区长春站 G hdu 5533 Dancing Stars on Me的更多相关文章
- 2015ACM/ICPC亚洲区长春站 F hdu 5533 Almost Sorted Array
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- 2015ACM/ICPC亚洲区长春站 B hdu 5528 Count a * b
Count a * b Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Tot ...
- 2015ACM/ICPC亚洲区长春站 L hdu 5538 House Building
House Building Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) ...
- 2015ACM/ICPC亚洲区长春站 J hdu 5536 Chip Factory
Chip Factory Time Limit: 18000/9000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)T ...
- 2015ACM/ICPC亚洲区长春站 H hdu 5534 Partial Tree
Partial Tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)To ...
- 2015ACM/ICPC亚洲区长春站 E hdu 5531 Rebuild
Rebuild Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total S ...
- 2015ACM/ICPC亚洲区长春站 A hdu 5527 Too Rich
Too Rich Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
- hdu 5533 Dancing Stars on Me(数学,水)
Problem Description The sky was brushed clean by the wind and the stars were cold in a black sky. Wh ...
- hdu 5533 Dancing Stars on Me
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5533 Dancing Stars on Me Time Limit: 2000/1000 MS (Ja ...
随机推荐
- Unity3D研究院之Jenkins的使用(七十八)
长夜漫漫无心睡眠,来一篇嘿嘿.我相信如果已经用Shell脚本完成IOS和Android打包的朋友一定需要Jenkins 怎么才能让策划打包ipa和apk?怎么才能彻底省去程序的时间,只要在同一局域网内 ...
- NGUI 新版操作教程
http://www.tasharen.com/forum/index.php?topic=6754
- [BZOJ3872][Poi2014]Ant colony
[BZOJ3872][Poi2014]Ant colony 试题描述 There is an entrance to the ant hill in every chamber with only o ...
- window 安装 sass compass 记录
1.安装Ruby 安装sass 和compass 需要 Ruby 的环境,还区分xp 和win7-8 下版本区别 ruby 官网中文 ruby 官网英文 注意: xp: 下载 [xp不能下载包含64位 ...
- 开发jquery tab 插件
开发最简单的效果- -,基本构架 html,可以换更有意义的结构,这里demo,就简单写,不考虑SEO <div id="tab-hd"> <div class= ...
- MySql 插入数据中文乱码
在数据库连接URL后加上characterEncoding=UTF-8 driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/ssm ...
- bash read命令用法
read -p "Enter your student ID: " USERNAMEread -s -p "Enter your password: " PAS ...
- CheckBoxList1复选框
循环绑定数据的两个方法: List<string> LIColl = new List<string>(); protected void Page_Load(object s ...
- iterator与const_iterator及const iterator区别
如果你传递过来一个const类型的容器,那么只能用const_iterator来遍历. C++ Code 12345 void Method(const vector<int> v ...
- Java for LeetCode 139 Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...