#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> p, r;
int n;
int get(int v)
{
return p[v] == 0 ? v : p[v] = get(p[v]);
}
void unio(int a, int b)
{
a = get(a);
b = get(b);
if(a != b)
{
if(r[a] < r[b]) swap(a, b);
p[b] = a;
if(r[a] == r[b]) r[a]++;
}
}
struct val
{
ll a, b, d;
};
bool insc(ll xa, ll xb, ll ya, ll yb)
{
long double b = (yb - ya) / (xb - xa);
if(b == 0) return 0;
long double x = -1;
//xa + (-ya / b);
return x > 0;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
p.resize(2 * n + 1);
r.resize(2 * n + 1);
vector<ll> x(n + 1), y(n + 1);
vector<val> e;
for(int i = 1; i <= n; i++)
{
cin >> x[i] >> y[i];
for(int j = 1; j < i; j++)
{
ll dx = x[i] - x[j], dy = y[i] - y[j];
e.push_back({j, i, dx * dx + dy * dy});
}
}
sort(e.begin(), e.end(), [](val a, val b)
{
return a.d < b.d;
});
for(auto [a, b, d] : e)
{
bool g = insc(x[a], x[b], y[a], y[b]);
if(g)
{
unio(a, b + n);
unio(a + n, b);
}
else
{
unio(a, b);
unio(a + n, b + n);
}
if(get(a) == get(a + n))
{
cout << d << "\n";
return 0;
}
}
cout << "-1\n";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1696 KiB | ||||
2 | Wrong answer | 3ms | 1932 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Wrong answer | 3ms | 2160 KiB | ||||
4 | Wrong answer | 3ms | 2364 KiB | ||||
5 | Wrong answer | 3ms | 2584 KiB | ||||
6 | Wrong answer | 3ms | 2804 KiB | ||||
7 | Wrong answer | 3ms | 2960 KiB | ||||
8 | Wrong answer | 3ms | 3212 KiB | ||||
9 | Wrong answer | 3ms | 3276 KiB | ||||
10 | Wrong answer | 3ms | 3344 KiB | ||||
11 | Accepted | 3ms | 3448 KiB | ||||
12 | Accepted | 3ms | 3552 KiB | ||||
subtask3 | 0/20 | ||||||
13 | Wrong answer | 3ms | 2160 KiB | ||||
14 | Wrong answer | 3ms | 2364 KiB | ||||
15 | Wrong answer | 3ms | 2584 KiB | ||||
16 | Wrong answer | 3ms | 2804 KiB | ||||
17 | Wrong answer | 3ms | 2960 KiB | ||||
18 | Wrong answer | 3ms | 3212 KiB | ||||
19 | Wrong answer | 3ms | 3276 KiB | ||||
20 | Wrong answer | 3ms | 3344 KiB | ||||
21 | Accepted | 3ms | 3448 KiB | ||||
22 | Accepted | 3ms | 3552 KiB | ||||
23 | Wrong answer | 3ms | 3536 KiB | ||||
24 | Wrong answer | 3ms | 3756 KiB | ||||
25 | Wrong answer | 3ms | 3848 KiB | ||||
26 | Wrong answer | 3ms | 3840 KiB | ||||
27 | Wrong answer | 3ms | 3840 KiB | ||||
28 | Wrong answer | 3ms | 3736 KiB | ||||
29 | Accepted | 3ms | 3824 KiB | ||||
30 | Accepted | 3ms | 3820 KiB | ||||
31 | Wrong answer | 3ms | 3636 KiB | ||||
subtask4 | 0/20 | ||||||
32 | Wrong answer | 3ms | 2160 KiB | ||||
33 | Wrong answer | 3ms | 2364 KiB | ||||
34 | Wrong answer | 3ms | 2584 KiB | ||||
35 | Wrong answer | 3ms | 2804 KiB | ||||
36 | Wrong answer | 3ms | 2960 KiB | ||||
37 | Wrong answer | 3ms | 3212 KiB | ||||
38 | Wrong answer | 3ms | 3276 KiB | ||||
39 | Wrong answer | 3ms | 3344 KiB | ||||
40 | Accepted | 3ms | 3448 KiB | ||||
41 | Accepted | 3ms | 3552 KiB | ||||
42 | Wrong answer | 3ms | 3536 KiB | ||||
43 | Wrong answer | 3ms | 3756 KiB | ||||
44 | Wrong answer | 3ms | 3848 KiB | ||||
45 | Wrong answer | 3ms | 3840 KiB | ||||
46 | Wrong answer | 3ms | 3840 KiB | ||||
47 | Wrong answer | 3ms | 3736 KiB | ||||
48 | Accepted | 3ms | 3824 KiB | ||||
49 | Accepted | 3ms | 3820 KiB | ||||
50 | Wrong answer | 3ms | 3636 KiB | ||||
51 | Wrong answer | 4ms | 4096 KiB | ||||
52 | Wrong answer | 3ms | 4096 KiB | ||||
53 | Wrong answer | 3ms | 4384 KiB | ||||
54 | Wrong answer | 4ms | 4532 KiB | ||||
55 | Wrong answer | 3ms | 4408 KiB | ||||
56 | Wrong answer | 3ms | 4320 KiB | ||||
57 | Wrong answer | 3ms | 4344 KiB | ||||
58 | Wrong answer | 3ms | 4504 KiB | ||||
59 | Wrong answer | 4ms | 4552 KiB | ||||
60 | Wrong answer | 3ms | 4480 KiB | ||||
61 | Wrong answer | 3ms | 4472 KiB | ||||
62 | Wrong answer | 3ms | 4480 KiB | ||||
63 | Wrong answer | 3ms | 4732 KiB | ||||
64 | Wrong answer | 3ms | 4648 KiB | ||||
65 | Wrong answer | 3ms | 4656 KiB | ||||
66 | Wrong answer | 3ms | 4824 KiB | ||||
67 | Accepted | 3ms | 4828 KiB | ||||
68 | Accepted | 3ms | 4796 KiB | ||||
69 | Accepted | 3ms | 4756 KiB | ||||
70 | Accepted | 3ms | 4792 KiB | ||||
subtask5 | 0/40 | ||||||
71 | Wrong answer | 3ms | 2160 KiB | ||||
72 | Wrong answer | 3ms | 2364 KiB | ||||
73 | Wrong answer | 3ms | 2584 KiB | ||||
74 | Wrong answer | 3ms | 2804 KiB | ||||
75 | Wrong answer | 3ms | 2960 KiB | ||||
76 | Wrong answer | 3ms | 3212 KiB | ||||
77 | Wrong answer | 3ms | 3276 KiB | ||||
78 | Wrong answer | 3ms | 3344 KiB | ||||
79 | Accepted | 3ms | 3448 KiB | ||||
80 | Accepted | 3ms | 3552 KiB | ||||
81 | Wrong answer | 3ms | 3536 KiB | ||||
82 | Wrong answer | 3ms | 3756 KiB | ||||
83 | Wrong answer | 3ms | 3848 KiB | ||||
84 | Wrong answer | 3ms | 3840 KiB | ||||
85 | Wrong answer | 3ms | 3840 KiB | ||||
86 | Wrong answer | 3ms | 3736 KiB | ||||
87 | Accepted | 3ms | 3824 KiB | ||||
88 | Accepted | 3ms | 3820 KiB | ||||
89 | Wrong answer | 3ms | 3636 KiB | ||||
90 | Wrong answer | 4ms | 4096 KiB | ||||
91 | Wrong answer | 3ms | 4096 KiB | ||||
92 | Wrong answer | 3ms | 4384 KiB | ||||
93 | Wrong answer | 4ms | 4532 KiB | ||||
94 | Wrong answer | 3ms | 4408 KiB | ||||
95 | Wrong answer | 3ms | 4320 KiB | ||||
96 | Wrong answer | 3ms | 4344 KiB | ||||
97 | Wrong answer | 3ms | 4504 KiB | ||||
98 | Wrong answer | 4ms | 4552 KiB | ||||
99 | Wrong answer | 3ms | 4480 KiB | ||||
100 | Wrong answer | 3ms | 4472 KiB | ||||
101 | Wrong answer | 3ms | 4480 KiB | ||||
102 | Wrong answer | 3ms | 4732 KiB | ||||
103 | Wrong answer | 3ms | 4648 KiB | ||||
104 | Wrong answer | 3ms | 4656 KiB | ||||
105 | Wrong answer | 3ms | 4824 KiB | ||||
106 | Accepted | 3ms | 4828 KiB | ||||
107 | Accepted | 3ms | 4796 KiB | ||||
108 | Accepted | 3ms | 4756 KiB | ||||
109 | Accepted | 3ms | 4792 KiB | ||||
110 | Wrong answer | 93ms | 28964 KiB | ||||
111 | Wrong answer | 93ms | 29052 KiB | ||||
112 | Wrong answer | 92ms | 29056 KiB | ||||
113 | Wrong answer | 87ms | 29360 KiB | ||||
114 | Wrong answer | 93ms | 29448 KiB | ||||
115 | Wrong answer | 89ms | 29616 KiB | ||||
116 | Wrong answer | 96ms | 29792 KiB | ||||
117 | Wrong answer | 97ms | 29648 KiB | ||||
118 | Wrong answer | 97ms | 29616 KiB | ||||
119 | Wrong answer | 93ms | 29664 KiB | ||||
120 | Wrong answer | 96ms | 29588 KiB | ||||
121 | Wrong answer | 93ms | 29644 KiB | ||||
122 | Wrong answer | 96ms | 29632 KiB | ||||
123 | Wrong answer | 96ms | 29632 KiB | ||||
124 | Wrong answer | 96ms | 29628 KiB | ||||
125 | Wrong answer | 92ms | 29644 KiB | ||||
126 | Wrong answer | 96ms | 29592 KiB | ||||
127 | Wrong answer | 92ms | 29768 KiB | ||||
128 | Accepted | 94ms | 29888 KiB | ||||
129 | Wrong answer | 90ms | 29800 KiB | ||||
130 | Wrong answer | 94ms | 29924 KiB | ||||
131 | Accepted | 72ms | 29868 KiB | ||||
132 | Accepted | 94ms | 29868 KiB |