Logo
(追記) (追記ここまで)

28174번 - Range Closest Pair of Points Query 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
9 초 1024 MB113333.333%

문제

The closest pair of points problem is a well-known problem of computational geometry. In this problem, there are $n$ points $p_1,p_2,\ldots,p_n$ in the Euclidean plane. You will be given $q$ queries. In the $i$-th query, you will be given two integers $\ell_i$ and $r_i$ (1ドル\leq \ell_i< r_i\leq n$). You need to find a pair of points $(u,v)$ such that $\ell_i\leq u<v\leq r_i$ and the Euclidean distance $\sqrt{(x_u-x_v)^2+(y_u-y_v)^2}$ between point $p_u$ and $p_v$ is minimized.

입력

The first line of the input contains two integers $n$ and $q$ (2ドル \leq n\leq 250,000円,ドル 1ドル\leq q\leq 250,000円$), denoting the number of points and the number of queries.

In the next $n$ lines, the $i$-th line contains two integers $x_i$ and $y_i$ (1ドル\leq x_i,y_i\leq 10^8$), describing the coordinates of $p_i$.

Each of the next $q$ lines contains two integers $\ell_i$ and $r_i$ (1ドル\leq \ell_i< r_i\leq n$), denoting a query.

출력

For each query, print a single line containing an integer, denoting the value of $(x_u-x_v)^2+(y_u-y_v)^2$.

제한

예제 입력 1

5 5
2 4
1 1
3 3
5 1
4 2
1 5
2 3
2 4
3 5
1 3

예제 출력 1

2
8
8
2
2

예제 입력 2

2 1
1 1
1 1
1 2

예제 출력 2

0

힌트

출처

ICPC > Regionals > Asia East Continent > Hong Kong > 2023 ICPC Hong Kong Regional I번

Camp > Petrozavodsk Programming Camp > Winter 2023 > Day 3: 2023 ICPC Asia Hong Kong Regional I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /