-
Notifications
You must be signed in to change notification settings - Fork 0
/
CHEFSQUA(point to make sq).cpp
60 lines (53 loc) · 1.09 KB
/
CHEFSQUA(point to make sq).cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
#define M 2005
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int x1 , y11 , x2 , y2 , x3 , y3 , x4 , y4;
bool f;
void getsqpoint(ii a , ii b)
{
x3 = b.first - b.second + a.second; // 3 vertice of square
y3 = b.second + b.first - a.first;
x4 = a.first - b.second + a.second; // 4 vertice of square
y4 = a.second + b.first - a.first;
}
int main()
{
int N , x , y , require;
vector<ii> v;
set<ii> st;
bool f1 , f2;
scanf("%d",&N);
for (int i = 0; i < N; ++i)
{
scanf("%d %d" , &x , &y);
v.push_back(ii(x , y));
st.insert(ii(x , y));
}
if(st.size() <= 2) { require = 4 - st.size(); goto out; }
require = 2;
for (set<ii>::iterator i = st.begin(); i != st.end(); ++i)
{
for (set<ii>::iterator j = i; j != st.end(); ++j)
{
ii a = *i; ii b = *j;
if(a == b) continue;
getsqpoint(a,b);
f1 = st.count(ii(x3 , y3));
f2 = st.count(ii(x4 , y4));
if(f1 || f2)
{
if(f1 && f2)
{
require = 0;
goto out;
}
require = 1;
}
}
}
out:
printf("%d\n", require);
}