Poj Solution 2526

http://poj.org/problem?id=2526

#include "stdio.h"
#include "algorithm"
using namespace std;

struct point
{
    int x,y;
}p[10000];

inline bool cmp( point a, point b )
{
    return a.x < b.x || ( a.x == b.x && a.y < b.y );
}

int n;

int main()
{
    int cas,i,xx,yy;
    
    scanf( "%d", &cas );

    while( cas-- )
    {
        scanf( "%d", &n );
        
        for( i=0; i<n; i++ )
        {
            scanf( "%d %d", &p[i].x, &p[i].y );
        }

        sort( p, p+n, cmp );
        
        xx = p[0].x + p[n-1].x;
        yy = p[0].y + p[n-1].y;

        for( i=1; i<=n/2; i++ )
        {
            if( p[i].x + p[n-1-i].x != xx || p[i].y + p[n-1-i].y != yy )
                break;
        }

        if( i <= n/2 )printf( "non" );
        else printf( "yesn" );
    }

    return 0;
}


											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *