Submission details
Task:Closest points
Sender:aalto25k_004
Submission time:2025-11-12 16:57:40 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.07 sdetails
#30.08 sdetails
#40.06 sdetails
#5ACCEPTED0.00 sdetails
#60.04 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.04 sdetails
#110.00 sdetails
#120.00 sdetails
#130.05 sdetails
#14ACCEPTED0.00 sdetails
#150.00 sdetails
#160.04 sdetails
#170.04 sdetails
#180.00 sdetails

Code

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <climits>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll euclDist(pair<ll,ll> p1, pair<ll,ll> p2){
    return  pow((p1.first - p2.first),2) + pow((p1.second - p2.second),2);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n ;

    vector<pair<ll,ll>> arr(n);
    for(ll i = 0; i < n; i++){
        cin >> arr[i].first >> arr[i].second;
    }

    sort(arr.begin(), arr.end());

    ll d = 7999999984000000008;
    for(ll i = 0; i < n; i++){
        ll it = 1;

        while(i - it >= 0 ){
            it++;
            if(abs(arr[i-it-1].first - arr[i].first) > d) break;

            if(abs(arr[i-it-1].second - arr[i].second) > d) continue;
            
            ll dist = euclDist(arr[i], arr[i - it-1]);
            d = min(d, dist);
            
        }
    }

    cout << d << endl;
    return 0;

}

Test details

Test 1

Verdict:

input
100
58 36
81 -7
46 49
87 -58
...

correct output
1

user output
10

Feedback: Incorrect character on line 1 col 2: expected "1", got "10"

Test 2

Verdict:

input
200000
-222 -705
277 680
-436 561
528 -516
...

correct output
1

user output
(empty)

Test 3

Verdict:

input
200000
-464738043 865360844
465231470 129093134
-276549869 -21946314
111055008 -48821736
...

correct output
25413170

user output
(empty)

Test 4

Verdict:

input
200000
1 513001000
2 689002000
3 785003000
4 799004000
...

correct output
1000000

user output
(empty)

Test 5

Verdict: ACCEPTED

input
4
0 0
0 3
3 0
1 1

correct output
2

user output
2

Test 6

Verdict:

input
200000
1 0
1 1
1 2
1 3
...

correct output
1

user output
(empty)

Test 7

Verdict:

input
4
1 2
10 3
3 5
8 5

correct output
8

user output
34

Feedback: Incorrect character on line 1 col 1: expected "8", got "34"

Test 8

Verdict:

input
4
10 6
4 10
8 3
2 3

correct output
13

user output
73

Feedback: Incorrect character on line 1 col 1: expected "13", got "73"

Test 9

Verdict:

input
2
-999999999 -999999999
999999999 999999999

correct output
7999999984000000008

user output
1999999996000000000

Feedback: Incorrect character on line 1 col 1: expected "799999998400...", got "199999999600..."

Test 10

Verdict:

input
200000
0 1
1 1
2 1
3 1
...

correct output
1

user output
(empty)

Test 11

Verdict:

input
8
1 10000
-1 -10000
2 0
-2 0
...

correct output
16

user output
4

Feedback: Incorrect character on line 1 col 1: expected "16", got "4"

Test 12

Verdict:

input
3
-1000000000 -1000000000
1000000000 1000000000
0 0

correct output
2000000000000000000

user output
0

Feedback: Incorrect character on line 1 col 1: expected "200000000000...", got "0"

Test 13

Verdict:

input
199999
1 1
2 1
3 1
4 1
...

correct output
1

user output
(empty)

Test 14

Verdict: ACCEPTED

input
4
0 0
5 8
6 1
10000 0

correct output
37

user output
37

Test 15

Verdict:

input
435
-842 -199
-480 798
-176 -406
792 608
...

correct output
2

user output
68

Feedback: Incorrect character on line 1 col 1: expected "2", got "68"

Test 16

Verdict:

input
200000
1 0
1 2
1 4
1 6
...

correct output
4

user output
(empty)

Test 17

Verdict:

input
200000
0 1
2 1
4 1
6 1
...

correct output
4

user output
(empty)

Test 18

Verdict:

input
3
-1000000000 -1000000000
1000000000 1000000000
1000000000 -1000000000

correct output
4000000000000000000

user output
1999999870000004096

Feedback: Incorrect character on line 1 col 1: expected "400000000000...", got "199999987000..."