QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#92339#142. 平面最近点对Yansuan_HCl#0 3ms3844kbC++141.4kb2023-03-30 16:00:202023-03-30 16:00:21

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-30 16:00:21]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:3844kb
  • [2023-03-30 16:00:20]
  • 提交

answer

#include <bits/stdc++.h>
#define ms(x, v) memset(x, v, sizeof(x))
#define il __attribute__((always_inline))
#define U(i,l,r) for(int i=l,END##i=r; i<=END##i; ++i)
#define D(i,l,r) for(int i=l,END##i=r; i>=END##i; --i)
using namespace std;
using ll = __int128;
const ll INF = ll(0x3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f);

#define GC c=getchar()
#define IC isdigit(c)
void rd(auto &s) { s = 0; char GC;
	for (; !IC; GC);
	for (; IC; GC) s = s * 10 + c - 48;
} void rd(auto &s, auto &...t) { rd(s); rd(t...); }

const int N = 2000006;
struct Pt { ll x, y; } pt[N];
bool operator < (const Pt &l, const Pt &r) {
	return l.x == r.x ? l.y < r.y : l.x < r.x; }
bool cmp(const Pt &l, const Pt &r) { return l.y < r.y; }
ll Q(ll x) { return x * x; }

int n;
ll solve(int l, int r) {
	if (l == r) return INF;
	int mid((l + r) >> 1);
	ll mX = pt[mid].x;
	ll d = min(solve(l, mid), solve(mid + 1, r));
	inplace_merge(pt + l, pt + mid + 1, pt + r + 1, cmp);
	
	int p = l, q = l;
	U (i, l, r) {
		while (q < r && Q(pt[q + 1].y - pt[i].y) <= d)
			++q;
		while (p < q && Q(pt[i].y - pt[p].y) > d)
			++p;
		if (Q(pt[i].x - mX) > d) continue;
		U (j, p, q) if (i != j)
			d = min(d, Q(pt[i].x - pt[j].x) + Q(pt[i].y - pt[j].y));
	}
	return d;
}

int main() {
	rd(n);
	U (i, 1, n) rd(pt[i].x, pt[i].y);
	
	sort(pt + 1, pt + n + 1);
	ll ans = solve(1, n);
	printf("%.8lf", sqrt((long double)(ans)));
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3844kb

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:

0.00000000

result:

wrong answer 1st numbers differ - expected: '2.8284271', found: '0.0000000', error = '1.0000000'

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%