Submission details
Task:Closest points
Sender:aalto26jw_006
Submission time:2026-11-11 17:43:06 +0200
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.04 sdetails
#20.64 sdetails
#30.62 sdetails
#40.15 sdetails
#50.04 sdetails
#6ACCEPTED0.15 sdetails
#70.04 sdetails
#80.05 sdetails
#9ACCEPTED0.04 sdetails
#10ACCEPTED0.15 sdetails
#110.04 sdetails
#12ACCEPTED0.04 sdetails
#13ACCEPTED0.15 sdetails
#140.04 sdetails
#150.04 sdetails
#16ACCEPTED0.15 sdetails
#17ACCEPTED0.15 sdetails
#18ACCEPTED0.04 sdetails

Code

import sys


def dist(a, b):
    return ((b[0] - a[0]) ** 2) + ((b[1] - a[1]) ** 2)


def inW(p1, p2, d):
    x, y = p1
    d = d**0.5
    return (x - d <= p2[0] <= x) and (y - d <= p2[1] <= y + d)


def main():
    data = map(int, sys.stdin.buffer.read().split())
    it = iter(data)
    n = next(it)
    p = []

    for _ in range(n):
        p.append((next(it), next(it)))

    p.sort()

    d = dist(p[0], p[1])
    window = set()
    i = 0
    while i < n:
        for w in window:
            d = min(d, dist(p[i], w))

        i += 1
        if i == n:
            break
        newWindow = set()
        for w in window:
            if inW(p[i], w, d):
                newWindow.add(w)
        window = newWindow

    print(d)


main()

Test details

Test 1

Verdict:

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

correct output
1

user output
4357

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

Test 2

Verdict:

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

correct output
1

user output
100

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

Test 3

Verdict:

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

correct output
25413170

user output
1911509496787892625

Feedback: Incorrect character on line 1 col 1: expected "25413170", got "191150949678..."

Test 4

Verdict:

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

correct output
1000000

user output
30976352001000001

Feedback: Incorrect character on line 1 col 1: expected "1000000", got "309763520010..."

Test 5

Verdict:

input
4
0 0
0 3
3 0
1 1

correct output
2

user output
9

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

Test 6

Verdict: ACCEPTED

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

correct output
1

user output
1

Test 7

Verdict:

input
4
1 2
10 3
3 5
8 5

correct output
8

user output
13

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

Test 8

Verdict:

input
4
10 6
4 10
8 3
2 3

correct output
13

user output
53

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

Test 9

Verdict: ACCEPTED

input
2
-999999999 -999999999
999999999 999999999

correct output
7999999984000000008

user output
7999999984000000008

Test 10

Verdict: ACCEPTED

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

correct output
1

user output
1

Test 11

Verdict:

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

correct output
16

user output
25

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

Test 12

Verdict: ACCEPTED

input
3
-1000000000 -1000000000
1000000000 1000000000
0 0

correct output
2000000000000000000

user output
2000000000000000000

Test 13

Verdict: ACCEPTED

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

correct output
1

user output
1

Test 14

Verdict:

input
4
0 0
5 8
6 1
10000 0

correct output
37

user output
89

Feedback: Incorrect character on line 1 col 1: expected "37", got "89"

Test 15

Verdict:

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

correct output
2

user output
2253017

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

Test 16

Verdict: ACCEPTED

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

correct output
4

user output
4

Test 17

Verdict: ACCEPTED

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

correct output
4

user output
4

Test 18

Verdict: ACCEPTED

input
3
-1000000000 -1000000000
1000000000 1000000000
1000000000 -1000000000

correct output
4000000000000000000

user output
4000000000000000000