Dancing Stars on Me---hdu5533(判断是否为正多边形)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5533

题意:平面图中 有n个点给你每个点的坐标,判断是否能通过某种连线使得这些点所组成的n边形为 正n变形;

很容易发现在一个n变形中,所有的点之间的距离只有n/2种,所以我们只需判断一下这n个点之间的距离是否只有n/2种即可;

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<set>
using namespace std;
#define met(a, b) memset(a, b, sizeof(a))
#define N 105
#define INF 0x3f3f3f3f
typedef long long LL;

int d[N*N], x[N], y[N];

int main()
{
    int T, n;
    scanf("%d", &T);
    while(T--)
    {
        met(d, 0);
        int k = 0;
        scanf("%d", &n);
        for(int i=1; i<=n; i++)
        {
            scanf("%d %d", &x[i], &y[i]);
            for(int j=1; j<i; j++)
            {
                d[k++] = (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
            }
        }
        sort(d, d+k);
        int len = unique(d, d+k)-d;
        if(len == n/2)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

时间: 2024-08-24 00:45:04

Dancing Stars on Me---hdu5533(判断是否为正多边形)的相关文章

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 Problem Description The sky was brushed clean by the wind and the stars were cold in a bl

HDU 5533/ 2015长春区域 G.Dancing Stars on Me 暴力

Dancing Stars on Me Problem Description The sky was brushed clean by the wind and the stars were cold in a black sky. What a wonderful night. You observed that, sometimes the stars can form a regular polygon in the sky if we connect them properly. Yo

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): 1184    Accepted Submission(s): 651 Problem Description The sky was brushed clean by the wind and the stars were cold in a b

HDU-5533 Dancing Stars on Me

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1175    Accepted Submission(s): 643 Problem Description The sky was brushed clean by the wind and the stars were cold in a black sky. What a won

hdu 5533 正n边形判断 精度处理

Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1098    Accepted Submission(s): 598 Problem Description The sky was brushed clean by the wind and the stars were cold in a b

HDU5533(水不水?)

Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 286    Accepted Submission(s): 185 Problem Description The sky was brushed clean by the wind and the stars were cold in a bl

2015.11.1 ---2015---长春

Too Rich Count a * b Play a game Pipes selection Rebuild Almost Sorted Array Dancing Stars on Me Partial Tree 因为一棵树的每个节点的度数至少为 1 所以先给每个节点分配 1 个度数 然后剩下 n-2 的度数 dp[j] 表示已经用了 j 度数 的最优解 dp[j] = max(dp[j-i+1] + f[i]-f[1]) (i是枚举最终点的度数) 就相当于是在用度数更大的点去替换度数为

Dancing links

基本思路(Main Thoughts): Dancing link是一种十分优美的数据结构. 通常配合IDA*,二分等方法解决可以转化为精确覆盖和重复覆盖的题目. 精确覆盖:在一个01矩阵中选几行,使得这几行组合起来的矩阵每列有且只有一个1 重复覆盖:每列可以有多个1 实现步骤(Implementation Steps): 如果是正常的搜索 解决步骤: 选最左边第一个没有被删除的列 选择一个在1中选出的列中有1的行,其他行直接删除 删掉2中选出的行剩余的元素所在的列 重复1,直到有一次没有可选列

FZU 2148 Moon Game 判断凸边形

点击打开链接 Problem 2148 Moon Game Accept: 512    Submit: 1419 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Fat brother and Maze are playing a kind of special (hentai) game in the clearly blue sky which we can just consider as a k