Universal Cup Judging System

Universal Cup

Time Limit: 9 s Memory Limit: 1024 MB Total points: 100
الإحصائيات

有 $n$ 个点 $p_1,p_2,\dots,p_n$ 在二维平面上。

有 $q$ 次询问,在第 $i$ 个询问中,给定两个数 $l_i,r_i$ ($1\leq l_i< r_i\leq n$),你需要找到一对 $(u,v)$ 满足 $l_i\leq u< v\leq r_i$,$p_u$ 和 $p_v$ 之间的欧几里得距离 $\sqrt{(x_u-x_v)^2+(y_u-y_v)^2}$ 最小。

输入格式

第一行两个数 $n,q$ 表示点数以及询问数。

之后 $n$ 行,第 $i$ 行包含两个整数 $x_i,y_i$ 表示 $p_i$ 的坐标。

之后 $q$ 行,第 $i$ 行包含两个整数 $l_i,r_i$ ($1\leq l_i< r_i\leq n$) 表示第 $i$ 个询问。

输出格式

对每个询问,输出一行一个整数表示最小的 $(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

子任务

Idea:Claris,Solution:Claris,Code:Claris,Data:Claris&nzhtl1477

对于 $100\%$ 的数据,满足 $2 \leq n\leq 250\,000$, $1\leq q\leq 250\,000$,$1\leq x_i,y_i\leq 10^8$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.