#P1526. [NOI2003] 智破连环阵

[NOI2003] 智破连环阵

Description

After spending tens of billions, Country B finally developed a new weapon — the Linked Formation (Zenith Protected Linked Hybrid Zone). Legend says the Linked Formation is a self-sustaining intelligent weapon that never stalls. However, reconnaissance by Country A’s spies revealed that the Linked Formation actually consists of MM independent weapons numbered 1,2,,M1, 2, \ldots, M. Initially, weapon 11 is in the attack state, while all other weapons are in invincible defense. Thereafter, once weapon ii (1i<M1 \leq i < M) is destroyed, weapon i+1i+1 automatically switches from invincible defense to the attack state 11 second later. When weapon MM is destroyed, this expensive Linked Formation is destroyed.

To thoroughly defeat Country B’s scientists, the defense minister of Country A plans to use the cheapest weapon — bombs — to destroy the Linked Formation. After long and precise probing, Country A’s scientists obtained the planar coordinates of the MM weapons in the Linked Formation, then determined the planar coordinates of nn bombs and planted them. Each bomb has a continuous detonation duration of 55 minutes. During its activation window, each bomb can instantly eliminate any Country B weapon that is in the attack state and whose planar distance to it does not exceed kk. Similar to the Linked Formation, bomb a1a_1 detonates continuously for 55 minutes at first, then bomb a2a_2 detonates for 55 minutes, then bomb a3a_3, and so on, until the Linked Formation is destroyed.

Clearly, different sequences a1,a2,a3,a_1, a_2, a_3, \ldots have different effects. A good sequence may destroy the Linked Formation using only a small number of bombs; a bad sequence may fail even after using all bombs. Now, please determine an optimal sequence a1,a2,a3,a_1, a_2, a_3, \ldots such that the Linked Formation is destroyed during the detonation time of bomb axa_x. Here, xx should be as small as possible.

Input Format

The first line contains three integers: MM, nn, and kk, denoting that the Linked Formation of Country B consists of MM weapons, Country A has nn bombs available, and the bomb attack radius is kk. The next MM lines each contain a pair of integers xi,yix_i, y_i, representing the planar coordinates of weapon ii. Then the next nn lines each contain a pair of integers ui,viu_i, v_i, representing the planar coordinates of bomb ii. The input testdata is guaranteed to be random, correct, and to have a solution.

Output Format

One line containing an integer xx, the actual number of bombs used.

4 3 6
0 6
6 6
6 0
0 0
1 5
0 3
1 1

2

Hint

For 100%100\% of the testdata, 1M,n1001 \leq M, n \leq 100, 1k10001 \leq k \leq 1000, 0xi,yi100000 \leq x_i, y_i \leq 10000, 0ui,vi100000 \leq u_i, v_i \leq 10000.

Each test point has a time limit of 22 seconds.

Translated by ChatGPT 5