CF33D.Knights

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Berland is facing dark times again. The army of evil lord Van de Mart is going to conquer the whole kingdom. To the council of war called by the Berland's king Valery the Severe came n knights. After long discussions it became clear that the kingdom has exactly n control points (if the enemy conquers at least one of these points, the war is lost) and each knight will occupy one of these points.

Berland is divided into m + 1 regions with m fences, and the only way to get from one region to another is to climb over the fence. Each fence is a circle on a plane, no two fences have common points, and no control point is on the fence. You are given k pairs of numbers a__i, b__i. For each pair you have to find out: how many fences a knight from control point with index a__i has to climb over to reach control point b__i (in case when Van de Mart attacks control point b__i first). As each knight rides a horse (it is very difficult to throw a horse over a fence), you are to find out for each pair the minimum amount of fences to climb over.

贝尔兰再次面临黑暗时期。邪恶领主范·德·玛特的军队即将征服整个王国。贝尔兰国王——严厉者瓦莱里召开御前军事会议,共有 nn 名骑士出席。经过长时间的讨论,众人意识到王国恰好有 nn 个控制点(若敌人攻占其中任意一个控制点,则战争即告失败),且每名骑士将驻守其中一个控制点。

贝尔兰被 mm 道围栏划分为 m+1m+1 个区域,而从一个区域进入另一个区域的唯一方式是翻越围栏。每道围栏在平面上是一个圆,任意两道围栏互不相交(无公共点),且没有任何控制点位于围栏上。现给出 kk 对整数 (ai,bi)(a_i, b_i)。对每一对,你需要计算:一名驻守在编号为 aia_i 的控制点上的骑士,为抵达编号为 bib_i 的控制点(即当范·德·玛特首先进攻控制点 bib_i 时),需要翻越多少道围栏。由于每名骑士均骑马(将马翻越围栏极为困难),因此对每一对,你需找出需翻越的围栏数量的最小值。

输入格式

The first input line contains three integers n, m, k (1 ≤ n, m ≤ 1000, 0 ≤ k ≤ 100000). Then follow n lines, each containing two integers Kx__i, Ky__i ( - 109 ≤ Kx__i, Ky__i ≤ 109) — coordinates of control point with index i. Control points can coincide.

Each of the following m lines describes fence with index i with three integers r__i, Cx__i, Cy__i (1 ≤ r__i ≤ 109,  - 109 ≤ Cx__i, Cy__i ≤ 109) — radius and center of the circle where the corresponding fence is situated.

Then follow k pairs of integers a__i, b__i (1 ≤ a__i, b__i ≤ n), each in a separate line — requests that you have to answer. a__i and b__i can coincide.

第一行输入包含三个整数 nn、mm、kk(1≤n,m≤10001 \leq n, m \leq 1000,0≤k≤1000000 \leq k \leq 100000)。接下来是 nn 行,每行包含两个整数 KxiKx_i、KyiKy_i(−109≤Kxi,Kyi≤109-10^9 \leq Kx_i, Ky_i \leq 10^9)——表示编号为 ii 的控制点的坐标。控制点可以重合。

接下来的 mm 行每行描述一个编号为 ii 的围栏,包含三个整数 rir_i、CxiCx_i、CyiCy_i(1≤ri≤1091 \leq r_i \leq 10^9,−109≤Cxi,Cyi≤109-10^9 \leq Cx_i, Cy_i \leq 10^9)——分别表示该围栏所在圆的半径及圆心坐标。

随后是 kk 对整数 aia_i、bib_i(1≤ai,bi≤n1 \leq a_i, b_i \leq n),每对占一行——表示你需要回答的查询。aia_i 和 bib_i 可以相等。

输出格式

Output exactly k lines, each containing one integer — the answer to the corresponding request.

输出恰好 k 行,每行包含一个整数——对应查询的答案。

输入输出样例

  • 输入#1

    2 1 1
    0 0
    3 3
    2 0 0
    1 2

    输出#1

    1
  • 输入#2

    2 3 1
    0 0
    4 4
    1 0 0
    2 0 0
    3 0 0
    1 2

    输出#2

    3

输入解题思路,AI测评打分。不知道怎么写?

首页