#include <bits/stdc++.h>
using namespace std;
#define int long long
int sign(int x) {
return (x > 0) - (x < 0);
}
int cross(int x1, int y1, int x2, int y2) {
return x1 * y2 - y1 * x2;
}
int orient(int x1, int y1, int x2, int y2, int x3, int y3) {
return sign(cross(x1 - x2, y1 - y2, x3 - x2, y3 - y2));
}
bool test(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
int o1 = orient(x1, y1, x2, y2, x3, y3);
int o2 = orient(x1, y1, x2, y2, x4, y4);
int o3 = orient(x3, y3, x4, y4, x1, y1);
int o4 = orient(x3, y3, x4, y4, x2, y2);
return o1 != o2 && o3 != o4;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin>>N;
struct Pt{
int x,y;
};
vector<Pt>v(N);
for(int i=0;i<N;i++){
cin>>v[i].x>>v[i].y;
}
vector<pair<int,pair<int,int>>>e;
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
e.emplace_back((v[i].x-v[j].x)*(v[i].x-v[j].x)+(v[i].y-v[j].y)*(v[i].y-v[j].y),make_pair(i,j));
}
}
sort(e.begin(),e.end());
vector<vector<int>>g(N);
vector<int>p;
auto dfs=[&](auto self,int i,int j,int t)->bool{
if(j==t){
p.push_back(j);
return true;
}
for(int k:g[j]){
if(k==i){
continue;
}
if(self(self,j,k,t)){
p.push_back(j);
return true;
}
}
return false;
};
auto check=[&]()->bool{
int c=0;
for(int i=0;i<p.size();i++){
int j=(i+1)%p.size();
c+=test(v[p[i]].x,v[p[i]].y,v[p[j]].x,v[p[j]].y,0,0,1e9+7,1e9+9);
}
return c%2;
};
for(int i=0;i<e.size();){
int ans=e[i].first;
while(i<e.size()&&e[i].first==ans){
auto[a,b]=e[i].second;
p.clear();
if(dfs(dfs,-1,a,b)){
if(check()){
cout<<ans<<'\n';
return 0;
}
}
else {
g[a].push_back(b);
g[b].push_back(a);
}
i++;
}
}
cout<<-1<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2080 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 3ms | 2292 KiB | ||||
4 | Accepted | 3ms | 2396 KiB | ||||
5 | Accepted | 3ms | 2612 KiB | ||||
6 | Accepted | 3ms | 2692 KiB | ||||
7 | Accepted | 3ms | 2632 KiB | ||||
8 | Accepted | 3ms | 2892 KiB | ||||
9 | Accepted | 3ms | 2880 KiB | ||||
10 | Accepted | 3ms | 3004 KiB | ||||
11 | Accepted | 3ms | 3220 KiB | ||||
12 | Accepted | 3ms | 3192 KiB | ||||
subtask3 | 0/20 | ||||||
13 | Accepted | 3ms | 2292 KiB | ||||
14 | Accepted | 3ms | 2396 KiB | ||||
15 | Accepted | 3ms | 2612 KiB | ||||
16 | Accepted | 3ms | 2692 KiB | ||||
17 | Accepted | 3ms | 2632 KiB | ||||
18 | Accepted | 3ms | 2892 KiB | ||||
19 | Accepted | 3ms | 2880 KiB | ||||
20 | Accepted | 3ms | 3004 KiB | ||||
21 | Accepted | 3ms | 3220 KiB | ||||
22 | Accepted | 3ms | 3192 KiB | ||||
23 | Accepted | 3ms | 3476 KiB | ||||
24 | Accepted | 3ms | 3676 KiB | ||||
25 | Accepted | 3ms | 3648 KiB | ||||
26 | Accepted | 3ms | 3860 KiB | ||||
27 | Accepted | 3ms | 3956 KiB | ||||
28 | Accepted | 3ms | 4084 KiB | ||||
29 | Accepted | 3ms | 4064 KiB | ||||
30 | Accepted | 3ms | 4164 KiB | ||||
31 | Accepted | 3ms | 4296 KiB | ||||
subtask4 | 0/20 | ||||||
32 | Accepted | 3ms | 2292 KiB | ||||
33 | Accepted | 3ms | 2396 KiB | ||||
34 | Accepted | 3ms | 2612 KiB | ||||
35 | Accepted | 3ms | 2692 KiB | ||||
36 | Accepted | 3ms | 2632 KiB | ||||
37 | Accepted | 3ms | 2892 KiB | ||||
38 | Accepted | 3ms | 2880 KiB | ||||
39 | Accepted | 3ms | 3004 KiB | ||||
40 | Accepted | 3ms | 3220 KiB | ||||
41 | Accepted | 3ms | 3192 KiB | ||||
42 | Accepted | 3ms | 3476 KiB | ||||
43 | Accepted | 3ms | 3676 KiB | ||||
44 | Accepted | 3ms | 3648 KiB | ||||
45 | Accepted | 3ms | 3860 KiB | ||||
46 | Accepted | 3ms | 3956 KiB | ||||
47 | Accepted | 3ms | 4084 KiB | ||||
48 | Accepted | 3ms | 4064 KiB | ||||
49 | Accepted | 3ms | 4164 KiB | ||||
50 | Accepted | 3ms | 4296 KiB | ||||
51 | Accepted | 4ms | 4596 KiB | ||||
52 | Accepted | 3ms | 4600 KiB | ||||
53 | Accepted | 3ms | 4632 KiB | ||||
54 | Accepted | 3ms | 4764 KiB | ||||
55 | Accepted | 3ms | 4772 KiB | ||||
56 | Accepted | 3ms | 4680 KiB | ||||
57 | Accepted | 3ms | 4680 KiB | ||||
58 | Accepted | 3ms | 4688 KiB | ||||
59 | Accepted | 3ms | 4692 KiB | ||||
60 | Accepted | 3ms | 4724 KiB | ||||
61 | Accepted | 3ms | 4700 KiB | ||||
62 | Accepted | 3ms | 4732 KiB | ||||
63 | Accepted | 3ms | 4744 KiB | ||||
64 | Accepted | 3ms | 4744 KiB | ||||
65 | Accepted | 4ms | 4784 KiB | ||||
66 | Accepted | 7ms | 4764 KiB | ||||
67 | Accepted | 8ms | 5020 KiB | ||||
68 | Accepted | 8ms | 5012 KiB | ||||
69 | Accepted | 10ms | 4988 KiB | ||||
70 | Accepted | 8ms | 4988 KiB | ||||
subtask5 | 0/40 | ||||||
71 | Accepted | 3ms | 2292 KiB | ||||
72 | Accepted | 3ms | 2396 KiB | ||||
73 | Accepted | 3ms | 2612 KiB | ||||
74 | Accepted | 3ms | 2692 KiB | ||||
75 | Accepted | 3ms | 2632 KiB | ||||
76 | Accepted | 3ms | 2892 KiB | ||||
77 | Accepted | 3ms | 2880 KiB | ||||
78 | Accepted | 3ms | 3004 KiB | ||||
79 | Accepted | 3ms | 3220 KiB | ||||
80 | Accepted | 3ms | 3192 KiB | ||||
81 | Accepted | 3ms | 3476 KiB | ||||
82 | Accepted | 3ms | 3676 KiB | ||||
83 | Accepted | 3ms | 3648 KiB | ||||
84 | Accepted | 3ms | 3860 KiB | ||||
85 | Accepted | 3ms | 3956 KiB | ||||
86 | Accepted | 3ms | 4084 KiB | ||||
87 | Accepted | 3ms | 4064 KiB | ||||
88 | Accepted | 3ms | 4164 KiB | ||||
89 | Accepted | 3ms | 4296 KiB | ||||
90 | Accepted | 4ms | 4596 KiB | ||||
91 | Accepted | 3ms | 4600 KiB | ||||
92 | Accepted | 3ms | 4632 KiB | ||||
93 | Accepted | 3ms | 4764 KiB | ||||
94 | Accepted | 3ms | 4772 KiB | ||||
95 | Accepted | 3ms | 4680 KiB | ||||
96 | Accepted | 3ms | 4680 KiB | ||||
97 | Accepted | 3ms | 4688 KiB | ||||
98 | Accepted | 3ms | 4692 KiB | ||||
99 | Accepted | 3ms | 4724 KiB | ||||
100 | Accepted | 3ms | 4700 KiB | ||||
101 | Accepted | 3ms | 4732 KiB | ||||
102 | Accepted | 3ms | 4744 KiB | ||||
103 | Accepted | 3ms | 4744 KiB | ||||
104 | Accepted | 4ms | 4784 KiB | ||||
105 | Accepted | 7ms | 4764 KiB | ||||
106 | Accepted | 8ms | 5020 KiB | ||||
107 | Accepted | 8ms | 5012 KiB | ||||
108 | Accepted | 10ms | 4988 KiB | ||||
109 | Accepted | 8ms | 4988 KiB | ||||
110 | Accepted | 108ms | 29176 KiB | ||||
111 | Accepted | 100ms | 29236 KiB | ||||
112 | Accepted | 98ms | 29272 KiB | ||||
113 | Accepted | 96ms | 29244 KiB | ||||
114 | Accepted | 98ms | 29272 KiB | ||||
115 | Accepted | 101ms | 29288 KiB | ||||
116 | Accepted | 86ms | 29312 KiB | ||||
117 | Accepted | 85ms | 29360 KiB | ||||
118 | Accepted | 86ms | 29508 KiB | ||||
119 | Accepted | 86ms | 29456 KiB | ||||
120 | Accepted | 86ms | 29492 KiB | ||||
121 | Accepted | 83ms | 29484 KiB | ||||
122 | Accepted | 90ms | 29504 KiB | ||||
123 | Accepted | 89ms | 29528 KiB | ||||
124 | Accepted | 90ms | 29700 KiB | ||||
125 | Accepted | 87ms | 30144 KiB | ||||
126 | Time limit exceeded | 1.054s | 17164 KiB | ||||
127 | Time limit exceeded | 1.07s | 17140 KiB | ||||
128 | Time limit exceeded | 1.059s | 17152 KiB | ||||
129 | Time limit exceeded | 1.062s | 17220 KiB | ||||
130 | Time limit exceeded | 1.065s | 17228 KiB | ||||
131 | Time limit exceeded | 1.074s | 17192 KiB | ||||
132 | Time limit exceeded | 1.078s | 17236 KiB |