QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#128057 | #142. 平面最近点对 | 1234567890# | 0 | 2ms | 5880kb | C++14 | 1.7kb | 2023-07-20 15:15:06 | 2023-07-20 15:15:10 |
Judging History
answer
/*
灏忓簾鐗╋紝杩欓兘涓嶄細 /cf
*/
#include <bits/stdc++.h>
using namespace std;
#define ll __int128
#define mp make_pair
#define inf (ll)1e9
#define pii pair <ll, ll>
#define fr first
#define se second
const ll mod = 1e9 + 7;
char buf[1 << 21], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 18, stdin), p1 == p2) ? EOF : *p1++)
inline ll read() {
ll x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9') f = ((ch == '-') ? -1 : f), ch = getchar();
while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
return x * f;
}
inline void write(ll x) {
if(x < 0) x = -x, putchar('-');
if(x >= 10) write(x / 10);
putchar(x % 10 + '0');
}
inline ll Dis(pii x, pii y) {
return (x.fr - y.fr) * (x.fr - y.fr) + (x.se - y.se) * (x.se - y.se);
}
ll n;
pii a[2000005];
set <pii> S;
int main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
n = read();
for(ll i = 1; i <= n; i++) a[i].fr = read(), a[i].se = read();
sort(a + 1, a + 1 + n);
for(ll i = 1; i <= n; i++) swap(a[i].fr, a[i].se);
ll d = Dis(a[1], a[2]);
S.insert(a[1]), S.insert(a[2]);
for(ll i = 3, j = 1; i <= n; i++) {
// printf("!! %lld\n", i);
while(j < i && (a[j].se - a[i].se) * (a[j].se - a[i].se) >= d) S.erase(a[j++]);
auto it = S.lower_bound(mp(a[i].fr, 0ll));
while(it != S.end()) {
if((a[j].fr - a[i].fr) * (a[j].fr - a[i].fr) >= d) break;
d = min(d, Dis((*it), a[i])), it++;
}
while(it != S.begin()) {
it--;
if((a[j].fr - a[i].fr) * (a[j].fr - a[i].fr) >= d) break;
d = min(d, Dis((*it), a[i]));
}
S.insert(a[i]);
}
printf("%.12Lf", sqrtl(d));
return 0;
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 5880kb
input:
2933 19320 28055 2053 27470 14635 1378 27582 9822 28729 107 22351 3093 17670 379 23901 4686 27182 12261 19443 8467 24208 20283 10763 10584 25953 28380 28290 27394 19572 14769 4024 12401 23295 3267 26949 176 13416 4517 23856 15413 26260 18957 18275 24409 999 3873 28202 14686 25446 2822 24009 8949 114...
output:
59.539902586417
result:
wrong answer 1st numbers differ - expected: '2.8284271', found: '59.5399026', error = '20.0505344'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%