#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll=long long;
struct point{
ll x,y;
};
struct edge{
int A,B,W;
ll D;
edge(int a,int b,int w,ll d){
A=a;B=b;W=w;D=d;
}
};
int n;
vector <point> v(1e3);
vector <edge> ed;
vector <int> p(2e3,0);
vector <int> sz(2e3,1);
int sgn(ll num){
return (num>0)-(num<0);
}
int turn(point a, point b,point c){
return sgn((c.y-a.y)*(b.x-a.x)-(b.y-a.y)*(c.x-a.x));
}
int intersection(point a,point b){
point c,d;
c.x=c.y=0;
d.x=1;d.y=1e9+1;
if (turn(a,b,c)*turn(a,b,d)>-1) return 0;
if (turn(c,d,a)*turn(c,d,b)>-1) return 0;
return 1;
}
ll dist(point a, point b){
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
bool srt(edge e,edge f){
return (e.D<f.D?true:false);
}
int holvan(int a){
return (a==p[a]?a:p[a]=holvan(p[a]));
}
void unio(int a,int b){
a=holvan(a);
b=holvan(b);
if (a==b) return;
if (sz[a]>sz[b]) swap(a,b);
p[a]=b;
sz[b]+=sz[a];
}
bool UNIO(edge e){
if (e.W){
unio(e.A,e.B+n);
unio(e.A+n,e.B);
}else{
unio(e.A,e.B);
unio(e.A+n,e.B+n);
}
return (holvan(e.A)==holvan(e.A+n)?true:false);
}
int main(){
cin >> n;
for (int i=0;i<n;i++){
cin >> v[i].x >> v[i].y;
for (int j=0;j<i;j++){
ed.push_back(edge(i,j,intersection(v[i],v[j]),dist(v[i],v[j])));
}
}
sort(ed.begin(),ed.end(),srt);
for (int i=0;i<2*n;i++) p[i]=i;
for (edge e : ed){
if (UNIO(e)){
cout << e.D;
return 0;
}
}
cout << -1;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1908 KiB | ||||
2 | Accepted | 3ms | 2244 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 3ms | 2508 KiB | ||||
4 | Accepted | 3ms | 2720 KiB | ||||
5 | Accepted | 3ms | 2960 KiB | ||||
6 | Accepted | 3ms | 3164 KiB | ||||
7 | Accepted | 2ms | 3000 KiB | ||||
8 | Accepted | 3ms | 3208 KiB | ||||
9 | Accepted | 3ms | 3424 KiB | ||||
10 | Accepted | 3ms | 3512 KiB | ||||
11 | Accepted | 2ms | 3588 KiB | ||||
12 | Accepted | 2ms | 3508 KiB | ||||
subtask3 | 20/20 | ||||||
13 | Accepted | 3ms | 2508 KiB | ||||
14 | Accepted | 3ms | 2720 KiB | ||||
15 | Accepted | 3ms | 2960 KiB | ||||
16 | Accepted | 3ms | 3164 KiB | ||||
17 | Accepted | 2ms | 3000 KiB | ||||
18 | Accepted | 3ms | 3208 KiB | ||||
19 | Accepted | 3ms | 3424 KiB | ||||
20 | Accepted | 3ms | 3512 KiB | ||||
21 | Accepted | 2ms | 3588 KiB | ||||
22 | Accepted | 2ms | 3508 KiB | ||||
23 | Accepted | 3ms | 3652 KiB | ||||
24 | Accepted | 2ms | 3736 KiB | ||||
25 | Accepted | 3ms | 3976 KiB | ||||
26 | Accepted | 2ms | 3860 KiB | ||||
27 | Accepted | 3ms | 4008 KiB | ||||
28 | Accepted | 3ms | 3928 KiB | ||||
29 | Accepted | 3ms | 3988 KiB | ||||
30 | Accepted | 3ms | 4064 KiB | ||||
31 | Accepted | 2ms | 4128 KiB | ||||
subtask4 | 20/20 | ||||||
32 | Accepted | 3ms | 2508 KiB | ||||
33 | Accepted | 3ms | 2720 KiB | ||||
34 | Accepted | 3ms | 2960 KiB | ||||
35 | Accepted | 3ms | 3164 KiB | ||||
36 | Accepted | 2ms | 3000 KiB | ||||
37 | Accepted | 3ms | 3208 KiB | ||||
38 | Accepted | 3ms | 3424 KiB | ||||
39 | Accepted | 3ms | 3512 KiB | ||||
40 | Accepted | 2ms | 3588 KiB | ||||
41 | Accepted | 2ms | 3508 KiB | ||||
42 | Accepted | 3ms | 3652 KiB | ||||
43 | Accepted | 2ms | 3736 KiB | ||||
44 | Accepted | 3ms | 3976 KiB | ||||
45 | Accepted | 2ms | 3860 KiB | ||||
46 | Accepted | 3ms | 4008 KiB | ||||
47 | Accepted | 3ms | 3928 KiB | ||||
48 | Accepted | 3ms | 3988 KiB | ||||
49 | Accepted | 3ms | 4064 KiB | ||||
50 | Accepted | 2ms | 4128 KiB | ||||
51 | Accepted | 4ms | 4508 KiB | ||||
52 | Accepted | 3ms | 4524 KiB | ||||
53 | Accepted | 4ms | 4536 KiB | ||||
54 | Accepted | 4ms | 4532 KiB | ||||
55 | Accepted | 4ms | 4536 KiB | ||||
56 | Accepted | 4ms | 4516 KiB | ||||
57 | Accepted | 4ms | 4652 KiB | ||||
58 | Accepted | 4ms | 4792 KiB | ||||
59 | Accepted | 4ms | 4728 KiB | ||||
60 | Accepted | 4ms | 5000 KiB | ||||
61 | Accepted | 3ms | 4960 KiB | ||||
62 | Accepted | 4ms | 5064 KiB | ||||
63 | Accepted | 4ms | 5332 KiB | ||||
64 | Accepted | 4ms | 5296 KiB | ||||
65 | Accepted | 3ms | 5316 KiB | ||||
66 | Accepted | 4ms | 5316 KiB | ||||
67 | Accepted | 4ms | 5296 KiB | ||||
68 | Accepted | 4ms | 5288 KiB | ||||
69 | Accepted | 4ms | 5316 KiB | ||||
70 | Accepted | 4ms | 5340 KiB | ||||
subtask5 | 40/40 | ||||||
71 | Accepted | 3ms | 2508 KiB | ||||
72 | Accepted | 3ms | 2720 KiB | ||||
73 | Accepted | 3ms | 2960 KiB | ||||
74 | Accepted | 3ms | 3164 KiB | ||||
75 | Accepted | 2ms | 3000 KiB | ||||
76 | Accepted | 3ms | 3208 KiB | ||||
77 | Accepted | 3ms | 3424 KiB | ||||
78 | Accepted | 3ms | 3512 KiB | ||||
79 | Accepted | 2ms | 3588 KiB | ||||
80 | Accepted | 2ms | 3508 KiB | ||||
81 | Accepted | 3ms | 3652 KiB | ||||
82 | Accepted | 2ms | 3736 KiB | ||||
83 | Accepted | 3ms | 3976 KiB | ||||
84 | Accepted | 2ms | 3860 KiB | ||||
85 | Accepted | 3ms | 4008 KiB | ||||
86 | Accepted | 3ms | 3928 KiB | ||||
87 | Accepted | 3ms | 3988 KiB | ||||
88 | Accepted | 3ms | 4064 KiB | ||||
89 | Accepted | 2ms | 4128 KiB | ||||
90 | Accepted | 4ms | 4508 KiB | ||||
91 | Accepted | 3ms | 4524 KiB | ||||
92 | Accepted | 4ms | 4536 KiB | ||||
93 | Accepted | 4ms | 4532 KiB | ||||
94 | Accepted | 4ms | 4536 KiB | ||||
95 | Accepted | 4ms | 4516 KiB | ||||
96 | Accepted | 4ms | 4652 KiB | ||||
97 | Accepted | 4ms | 4792 KiB | ||||
98 | Accepted | 4ms | 4728 KiB | ||||
99 | Accepted | 4ms | 5000 KiB | ||||
100 | Accepted | 3ms | 4960 KiB | ||||
101 | Accepted | 4ms | 5064 KiB | ||||
102 | Accepted | 4ms | 5332 KiB | ||||
103 | Accepted | 4ms | 5296 KiB | ||||
104 | Accepted | 3ms | 5316 KiB | ||||
105 | Accepted | 4ms | 5316 KiB | ||||
106 | Accepted | 4ms | 5296 KiB | ||||
107 | Accepted | 4ms | 5288 KiB | ||||
108 | Accepted | 4ms | 5316 KiB | ||||
109 | Accepted | 4ms | 5340 KiB | ||||
110 | Accepted | 126ms | 29524 KiB | ||||
111 | Accepted | 126ms | 29600 KiB | ||||
112 | Accepted | 126ms | 29596 KiB | ||||
113 | Accepted | 127ms | 29468 KiB | ||||
114 | Accepted | 126ms | 29376 KiB | ||||
115 | Accepted | 126ms | 29376 KiB | ||||
116 | Accepted | 136ms | 29456 KiB | ||||
117 | Accepted | 136ms | 29372 KiB | ||||
118 | Accepted | 133ms | 29452 KiB | ||||
119 | Accepted | 133ms | 29524 KiB | ||||
120 | Accepted | 136ms | 29524 KiB | ||||
121 | Accepted | 134ms | 29440 KiB | ||||
122 | Accepted | 131ms | 29520 KiB | ||||
123 | Accepted | 136ms | 29520 KiB | ||||
124 | Accepted | 135ms | 29444 KiB | ||||
125 | Accepted | 133ms | 29524 KiB | ||||
126 | Accepted | 141ms | 29452 KiB | ||||
127 | Accepted | 143ms | 29376 KiB | ||||
128 | Accepted | 144ms | 29448 KiB | ||||
129 | Accepted | 141ms | 29444 KiB | ||||
130 | Accepted | 144ms | 29784 KiB | ||||
131 | Accepted | 115ms | 29656 KiB | ||||
132 | Accepted | 149ms | 29872 KiB |