1095

12 篇文章 0 订阅

这道题并不顺利。。排序出了问题。。其实自己测样例的时候发现了。。但是今天没敲,,晚上重新写。。不过收获很大,,我没看题就想了方法,我目前知道的,,排序,,集合,,map

#include<cstdio>
#include<iostream>
#include<string.h>

using namespace std;

const int maxn = 1000 + 5;

struct node
{
    int x,y;
}a[maxn],b[maxn],temp;
int main()
{
    int N,n,mark = 0;
    cin >> N;
    for(int count = 1; count <= N; ++count)
    {
        mark = 0;
        cin >> n;
        for(int i = 0; i < n; ++i)cin >> a[i].x >> a[i].y;
        for(int i = 0; i < n - 1; ++i)
        {
            for(int j = i + 1; j < n; ++j)
            {
                if(a[i].x > a[j].x)
                {
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
                else if(a[i].x==a[j].x&&a[i].y > a[j].y)
                {
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
        }
        for(int i = 0; i < n; ++i)b[i] = a[n-i-1];
        for(int i = 0; i < n - 1; ++i)
        {
            for(int j = i + 1; j < n; ++j)
            {
                if(b[i].x==b[j].x&&b[i].y > b[j].y)
                {
                    temp = b[i];
                    b[i] = b[j];
                    b[j] = temp;
                }
            }
        }

        int x = a[0].x + b[0].x;
        for(int i = 0; i < n; ++i)
        {
            if(a[i].y==b[i].y&&a[i].x+b[i].x==x)continue;
            else if(a[i].y!=b[i].y&&2*a[i].x==x&&2*b[i].x==x)continue;
            else {mark = 1;break;}
        }
        if(mark==1)cout <<"NO"<< endl;
        else cout <<"YES"<<endl;
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值