#P16223. 【模板】旋转卡壳/最远点对

    ID: 18257 远端评测题 500ms 2048MiB 尝试: 1 已通过: 1 显示难度省选/NOI− 上传者: 标签>计算几何Special Judge旋转卡壳双指针 two-pointer模板题闵可夫斯基和 Minkowski sum

【模板】旋转卡壳/最远点对

Background

This problem comes from the repository https://github.com/yosupo06/library-checker-problems.

Problem Description

This problem has TT cases.

Given N N 2D points pi(xi,yi) p_i (x_i, y_i) (0≤i≤N−1)(0 \le i \le N - 1). Find a pair (i,j) (i, j) , such that i≠j i \ne j and $\text{dist}(p_i, p_j) = \max_{i \ne j} \text{dist}(p_i, p_j)$.

Here, dist\text{dist} denotes the Euclidean distance between two points.

Input Format

TT
NN
x0 y0x_0\ y_0
x1 y1x_1\ y_1
⋮\vdots
xN−1 yN−1x_{N-1}\ y_{N-1}
NN
x0 y0x_0\ y_0
x1 y1x_1\ y_1
⋮\vdots
xN−1 yN−1x_{N-1}\ y_{N-1}
⋮\vdots

4
5
-1 -1
-6 4
-9 -7
2 5
-7 6
2
1 2
3 4
3
1 1
1 1
1 1
2
-1000000000 1000000000
1000000000 -1000000000
3 2
0 1
0 1
0 1

Hint

  • 1≤T≤105 1 \le T \le 10^5
  • 2≤N≤5×105 2 \le N \le 5 \times 10^5
  • ∣xi∣,∣yi∣≤109 |x_i|, |y_i| \le 10^9
  • xi,yi x_i, y_i are integers
  • The sum of N N over all test cases does not exceed 5×105 5 \times 10^5