#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;
struct Node
{
int x, y;
}s[10001];
struct node
{
int a, b, c, d;
node( int aa, int bb, int cc, int dd )
{
a=aa;b=bb;c=cc;d=dd;
}
};
int n, m, t;
int ans, num;
int used[1001];
vector<node> v;
int cmp( const void *aa, const void *bb )
{
Node *a=( Node * )aa;
Node *b=( Node * )bb;
if( a->x == b->x )
return a->y - b->y;
return a->x - b->x;//
}
int ok( int i, int j, int k, int kk )
{
if( s[i].x == s[j].x && s[i].y == s[k].y && s[k].x == s[kk].x && s[kk].y == s[j].y && s[j].y-s[i].y == s[k].x-s[i].x )//
return 1;
return 0;
}
void dfs( int i )
{
ans=max( ans, num );
for( ;i<v.size();i++ )
{
if( !used[v[i].a] && !used[v[i].b] && !used[v[i].c] && !used[v[i].d] )
{
num++;
used[v[i].a]=used[v[i].b]=used[v[i].c]=used[v[i].d]=1;
dfs( i+1 );
num--;//
used[v[i].a]=used[v[i].b]=used[v[i].c]=used[v[i].d]=0;
}
}
}
int main()
{
int i, j, k, kk;
int x, y;
while( scanf( "%d", &n ), n!=-1 )
{
memset( used, 0, sizeof( used ) );
for( i=0;i<n;i++ )
scanf( "%d%d", &s[i].x, &s[i].y );
qsort( s, n, sizeof( s[0] ), cmp );
v.clear();
for( i=0;i<n;i++ )
for( j=i+1;j<n;j++ )
for( k=j+1;k<n;k++ )
for( kk=k+1;kk<n;kk++ )
{
if( ok( i, j, k, kk ) )
v.push_back( node( i, j, k, kk ) );
}
ans=num=0;
dfs( 0 );
printf( "%d\n", 4*ans );
}
return 0;
}
vector dfs 4739 Zhuge Liang's Mines
最新推荐文章于 2016-08-17 12:08:25 发布