Created
September 15, 2013 07:47
-
-
Save XadillaX/6568741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 1002.c | |
// HDU | |
// | |
// Created by XadillaX on 13-9-15. | |
// Copyright (c) 2013年 XadillaX. All rights reserved. | |
// | |
#include <iostream> | |
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
int n; | |
struct coor { | |
int x, y; | |
}; | |
coor mat[25]; | |
struct matstr { | |
int huchi[100]; | |
int huchicnt; | |
coor c[4]; | |
}; | |
matstr square[100]; | |
int squarecnt = 0; | |
int huchi[100]; | |
int maxn = 0; | |
bool vsort(coor a, coor b) | |
{ | |
if(a.y < b.y) return true; | |
if(a.y > b.y) return false; | |
return a.x < b.x; | |
} | |
void dfs(int p, int ans) | |
{ | |
if(p == squarecnt) | |
{ | |
maxn = max(maxn, ans); | |
return; | |
} | |
// 不取 | |
dfs(p + 1, ans); | |
if(huchi[p]) return; | |
for(int i = 0; i < square[p].huchicnt; i++) | |
{ | |
huchi[square[p].huchi[i]]++; | |
} | |
ans += 4; | |
dfs(p + 1, ans); | |
ans -= 4; | |
for(int i = 0; i < square[p].huchicnt; i++) | |
{ | |
huchi[square[p].huchi[i]]--; | |
} | |
} | |
int main() | |
{ | |
while(~scanf("%d", &n)) | |
{ | |
if(n == -1) break; | |
for(int i = 0; i < n; i++) | |
{ | |
scanf("%d%d", &(mat[i].x), &(mat[i].y)); | |
} | |
squarecnt = 0; | |
for(int i = 0; i < n; i++) | |
{ | |
for(int j =i + 1; j < n; j++) | |
{ | |
for(int k = j + 1; k < n; k++) | |
{ | |
for(int l = k + 1; l < n; l++) | |
{ | |
coor v[4]; | |
v[0] = mat[i]; | |
v[1] = mat[j]; | |
v[2] = mat[k]; | |
v[3] = mat[l]; | |
sort(v, v + 4, vsort); | |
if(v[0].y == v[1].y && | |
v[2].y == v[3].y && | |
v[0].x == v[2].x && | |
v[1].x == v[3].x) | |
{ | |
if(v[2].y - v[0].y != v[1].x - v[0].x) continue; | |
memcpy(square[squarecnt].c, v, sizeof(v)); | |
square[squarecnt].huchicnt = 0; | |
squarecnt++; | |
} | |
} | |
} | |
} | |
} | |
for(int i = 0; i < squarecnt; i++) | |
{ | |
for(int j = i + 1; j < squarecnt; j++) | |
{ | |
// | |
bool ok = false; | |
for(int k = 0; k < 4; k++) | |
{ | |
for(int l = 0; l < 4; l++) | |
{ | |
if(square[i].c[k].x == square[j].c[l].x && | |
square[i].c[k].y == square[j].c[l].y) | |
{ | |
square[i].huchi[square[i].huchicnt++] = j; | |
square[j].huchi[square[j].huchicnt++] = i; | |
ok = true; | |
} | |
} | |
if(ok) break; | |
} | |
//if(ok) break; | |
} | |
} | |
maxn = 0; | |
memset(huchi, 0, sizeof(huchi)); | |
dfs(0, 0); | |
printf("%d\n", maxn); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment