| Task: | Closest points |
| Sender: | UnoK-admin |
| Submission time: | 2025-11-12 16:27:42 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | details |
| #2 | WRONG ANSWER | 0.10 s | details |
| #3 | WRONG ANSWER | 0.12 s | details |
| #4 | WRONG ANSWER | 0.31 s | details |
| #5 | WRONG ANSWER | 0.00 s | details |
| #6 | WRONG ANSWER | 0.24 s | details |
| #7 | WRONG ANSWER | 0.00 s | details |
| #8 | WRONG ANSWER | 0.00 s | details |
| #9 | WRONG ANSWER | 0.00 s | details |
| #10 | WRONG ANSWER | 0.05 s | details |
| #11 | WRONG ANSWER | 0.00 s | details |
| #12 | WRONG ANSWER | 0.00 s | details |
| #13 | WRONG ANSWER | 0.05 s | details |
| #14 | WRONG ANSWER | 0.00 s | details |
| #15 | WRONG ANSWER | 0.00 s | details |
| #16 | WRONG ANSWER | 0.31 s | details |
| #17 | WRONG ANSWER | 0.06 s | details |
| #18 | WRONG ANSWER | 0.00 s | details |
Code
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define VI vector<int>
#define AR(x) array<ll, x>
#define MX vector<VI >
#define all(x) x.begin(), x.end()
#define IOS cin.tie(0)->sync_with_stdio(0)
using namespace std;
int main(){
IOS;
int n;
cin >> n;
vector<AR(2) > p(n);
for(auto &[x, y] : p) cin >> x >> y;
sort(all(p));
auto swp = [](const AR(2) &a) -> AR(2) { return {a[1], a[0]}; };
auto dist = [](const AR(2) &a, const AR(2) &b){
return ((ll)a[0]-b[0])*((ll)a[0]-b[0])+((ll)a[1]-b[1])*((ll)a[1]-b[1]);
};
const int inf = 1e9+2;
ll ans = 8e18;
multiset<AR(2)> s;
int j = 0;
for(auto c : p){
while(j < n && ((ll)p[j][0]-c[0])*((ll)p[j][0]-c[0]) >= ans){
s.erase(s.find(swp(p[j++])));
}
auto l = s.upper_bound({c[1]-ans, -inf});
auto r = s.upper_bound({c[1]+ans, inf});
for(auto it = l; it!=r; it++){
cout << c[0] << ' ' << c[1] << ' ' << (*it)[0] << ' ' << (*it)[1] << '\n';
ans = min(ans, dist(*it, swp(c)));
}
s.insert(swp(c));
}
cout << ans << '\n';
return 0;
}
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 100 58 36 81 -7 46 49 87 -58 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| -96 -10 56 -97 -90 -93 -10 -96 -90 -93 56 -97 -89 -82 -93 -90 -89 -82 -10 -96 ... Truncated |
Feedback: Output is longer than expected
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 200000 -222 -705 277 680 -436 561 528 -516 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| -1000 -973 -983 -1000 -1000 -959 -983 -1000 -1000 -959 -973 -1000 -1000 -948 -983 -1000 -1 ... Truncated |
Feedback: Output is longer than expected
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 200000 -464738043 865360844 465231470 129093134 -276549869 -21946314 111055008 -48821736 ... |
| correct output |
|---|
| 25413170 |
| user output |
|---|
| -999988929 -448078121 93449538... Truncated |
Feedback: Output is longer than expected
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 200000 1 513001000 2 689002000 3 785003000 4 799004000 ... |
| correct output |
|---|
| 1000000 |
| user output |
|---|
| 2 689002000 513001000 1 3 785003000 513001000 1 3 785003000 689002000 2 4 799004000 513001 ... Truncated |
Feedback: Output is longer than expected
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 4 0 0 0 3 3 0 1 1 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 0 3 0 0 1 1 0 0 1 1 3 0 2 |
Feedback: Output is longer than expected
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 200000 1 0 1 1 1 2 1 3 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 1 0 1 1 2 1 1 1 3 2 1 1 4 3 1 1 5 4 1 ... Truncated |
Feedback: Output is longer than expected
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 4 1 2 10 3 3 5 8 5 |
| correct output |
|---|
| 8 |
| user output |
|---|
| 3 5 2 1 10 3 5 8 8 |
Feedback: Output is longer than expected
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 4 10 6 4 10 8 3 2 3 |
| correct output |
|---|
| 13 |
| user output |
|---|
| 4 10 3 2 8 3 3 2 8 3 10 4 10 6 3 8 13 |
Feedback: Output is longer than expected
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 2 -999999999 -999999999 999999999 999999999 |
| correct output |
|---|
| 7999999984000000008 |
| user output |
|---|
| 999999999 999999999 -999999999... |
Feedback: Output is longer than expected
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 200000 0 1 1 1 2 1 3 1 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 1 1 0 1 |
Feedback: Output is longer than expected
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 8 1 10000 -1 -10000 2 0 -2 0 ... |
| correct output |
|---|
| 16 |
| user output |
|---|
| -100 0 0 -105 2 0 0 -2 16 |
Feedback: Output is longer than expected
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 3 -1000000000 -1000000000 1000000000 1000000000 0 0 |
| correct output |
|---|
| 2000000000000000000 |
| user output |
|---|
| 0 0 -1000000000 -1000000000 1000000000 1000000000 0 0 2000000000000000000 |
Feedback: Output is longer than expected
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 199999 1 1 2 1 3 1 4 1 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 2 1 1 1 1 |
Feedback: Output is longer than expected
Test 14
Verdict: WRONG ANSWER
| input |
|---|
| 4 0 0 5 8 6 1 10000 0 |
| correct output |
|---|
| 37 |
| user output |
|---|
| 5 8 0 0 6 1 0 0 6 1 8 5 37 |
Feedback: Output is longer than expected
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| 435 -842 -199 -480 798 -176 -406 792 608 ... |
| correct output |
|---|
| 2 |
| user output |
|---|
| -984 -511 990 -988 -979 856 -511 -984 -979 856 990 -988 -972 -90 -511 -984 -972 -90 856 -9 ... Truncated |
Feedback: Output is longer than expected
Test 16
Verdict: WRONG ANSWER
| input |
|---|
| 200000 1 0 1 2 1 4 1 6 ... |
| correct output |
|---|
| 4 |
| user output |
|---|
| 1 2 0 1 1 4 0 1 1 4 2 1 1 6 2 1 1 6 4 1 ... Truncated |
Feedback: Output is longer than expected
Test 17
Verdict: WRONG ANSWER
| input |
|---|
| 200000 0 1 2 1 4 1 6 1 ... |
| correct output |
|---|
| 4 |
| user output |
|---|
| 2 1 1 0 4 |
Feedback: Output is longer than expected
Test 18
Verdict: WRONG ANSWER
| input |
|---|
| 3 -1000000000 -1000000000 1000000000 1000000000 1000000000 -1000000000 |
| correct output |
|---|
| 4000000000000000000 |
| user output |
|---|
| 1000000000 -1000000000 -100000... Truncated |
Feedback: Output is longer than expected
