109102024-04-18 20:10:48gortomiRajzcpp17Wrong answer 0/10092ms37832 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> p, r;
int n;
const int MAX =500000;
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 = xa + (-ya / b);
    return x > 0;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    p.resize(MAX);
    r.resize(MAX);
    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";
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted7ms9808 KiB
2Wrong answer6ms9880 KiB
subtask20/20
3Accepted6ms10140 KiB
4Wrong answer4ms10352 KiB
5Runtime error6ms10780 KiB
6Wrong answer6ms10436 KiB
7Wrong answer6ms10704 KiB
8Wrong answer6ms10864 KiB
9Accepted4ms10808 KiB
10Wrong answer6ms10868 KiB
11Accepted6ms10988 KiB
12Accepted4ms11240 KiB
subtask30/20
13Accepted6ms10140 KiB
14Wrong answer4ms10352 KiB
15Runtime error6ms10780 KiB
16Wrong answer6ms10436 KiB
17Wrong answer6ms10704 KiB
18Wrong answer6ms10864 KiB
19Accepted4ms10808 KiB
20Wrong answer6ms10868 KiB
21Accepted6ms10988 KiB
22Accepted4ms11240 KiB
23Runtime error6ms11744 KiB
24Runtime error6ms11656 KiB
25Wrong answer4ms11432 KiB
26Wrong answer6ms11556 KiB
27Wrong answer6ms11768 KiB
28Wrong answer6ms11884 KiB
29Accepted6ms11840 KiB
30Wrong answer6ms11976 KiB
31Runtime error6ms12256 KiB
subtask40/20
32Accepted6ms10140 KiB
33Wrong answer4ms10352 KiB
34Runtime error6ms10780 KiB
35Wrong answer6ms10436 KiB
36Wrong answer6ms10704 KiB
37Wrong answer6ms10864 KiB
38Accepted4ms10808 KiB
39Wrong answer6ms10868 KiB
40Accepted6ms10988 KiB
41Accepted4ms11240 KiB
42Runtime error6ms11744 KiB
43Runtime error6ms11656 KiB
44Wrong answer4ms11432 KiB
45Wrong answer6ms11556 KiB
46Wrong answer6ms11768 KiB
47Wrong answer6ms11884 KiB
48Accepted6ms11840 KiB
49Wrong answer6ms11976 KiB
50Runtime error6ms12256 KiB
51Runtime error7ms12976 KiB
52Runtime error7ms13044 KiB
53Runtime error7ms13124 KiB
54Runtime error7ms13044 KiB
55Runtime error6ms13156 KiB
56Wrong answer7ms13100 KiB
57Wrong answer7ms13036 KiB
58Wrong answer7ms13044 KiB
59Wrong answer7ms13188 KiB
60Wrong answer6ms13136 KiB
61Runtime error6ms13312 KiB
62Wrong answer7ms13124 KiB
63Runtime error6ms13208 KiB
64Wrong answer7ms12928 KiB
65Wrong answer6ms13016 KiB
66Runtime error7ms13100 KiB
67Wrong answer6ms12936 KiB
68Wrong answer7ms13020 KiB
69Accepted7ms13016 KiB
70Wrong answer7ms13012 KiB
subtask50/40
71Accepted6ms10140 KiB
72Wrong answer4ms10352 KiB
73Runtime error6ms10780 KiB
74Wrong answer6ms10436 KiB
75Wrong answer6ms10704 KiB
76Wrong answer6ms10864 KiB
77Accepted4ms10808 KiB
78Wrong answer6ms10868 KiB
79Accepted6ms10988 KiB
80Accepted4ms11240 KiB
81Runtime error6ms11744 KiB
82Runtime error6ms11656 KiB
83Wrong answer4ms11432 KiB
84Wrong answer6ms11556 KiB
85Wrong answer6ms11768 KiB
86Wrong answer6ms11884 KiB
87Accepted6ms11840 KiB
88Wrong answer6ms11976 KiB
89Runtime error6ms12256 KiB
90Runtime error7ms12976 KiB
91Runtime error7ms13044 KiB
92Runtime error7ms13124 KiB
93Runtime error7ms13044 KiB
94Runtime error6ms13156 KiB
95Wrong answer7ms13100 KiB
96Wrong answer7ms13036 KiB
97Wrong answer7ms13044 KiB
98Wrong answer7ms13188 KiB
99Wrong answer6ms13136 KiB
100Runtime error6ms13312 KiB
101Wrong answer7ms13124 KiB
102Runtime error6ms13208 KiB
103Wrong answer7ms12928 KiB
104Wrong answer6ms13016 KiB
105Runtime error7ms13100 KiB
106Wrong answer6ms12936 KiB
107Wrong answer7ms13020 KiB
108Accepted7ms13016 KiB
109Wrong answer7ms13012 KiB
110Runtime error82ms37116 KiB
111Runtime error82ms37120 KiB
112Runtime error82ms37120 KiB
113Runtime error89ms37028 KiB
114Runtime error90ms37156 KiB
115Runtime error83ms37296 KiB
116Wrong answer92ms37216 KiB
117Wrong answer92ms37320 KiB
118Wrong answer90ms37304 KiB
119Wrong answer86ms37316 KiB
120Wrong answer92ms37432 KiB
121Wrong answer92ms37312 KiB
122Runtime error87ms37428 KiB
123Wrong answer86ms37424 KiB
124Runtime error90ms37552 KiB
125Wrong answer90ms37424 KiB
126Runtime error90ms37688 KiB
127Runtime error86ms37832 KiB
128Runtime error90ms37688 KiB
129Runtime error85ms37640 KiB
130Wrong answer83ms37644 KiB
131Accepted82ms37644 KiB
132Wrong answer90ms37648 KiB