|
||||||||||
MinesTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1862 Accepted Submission(s): 489 Problem Description Terrorists put some mines in a crowded square recently. The police evacuate all people in time before any mine explodes. Now the police want all the mines be ignited. The police will take many operations to do the job. In each operation, the police will ignite one mine. Every mine has its "power distance". When a mine explodes, any other mine within the power distance of the exploding mine will also explode. Please NOTE that the distance is Manhattan distance here. More specifically, we put the mines in the Cartesian coordinate system. Each mine has position (x,y) and power distance d. The police want you to write a program and calculate the result of each operation. Input There are several test cases. In each test case: Line 1: an integer N, indicating that there are N mines. All mines are numbered from 1 to N. Line 2¡N+1: There are 3 integers in Line i+1 (i starts from 1). They are the i-th mine¡¯s position (xi,yi) and its power distance di. There can be more than one mine in the same point. Line N+2: an integer M, representing the number of operations. Line N+3...N+M+2 : Each line represents an operation by an integer k meaning that in this operation, the k-th mine will be ignited. It is possible to ignite a mine which has already exploded, but it will have no effect. 1<=M<=N<=100000£¬0<=xi,yi<=10^9£¬0<=di<=10^9 Input ends with N=0. Output For each test case, you should print ¡®Case #X:¡¯ at first, which X is the case number starting from 1. Then you print M lines, each line has an integer representing the number of mines explode in the correspondent operation. Sample Input
Sample Output
Source | ||||||||||
|