|
||||||||||
charge-stationTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1712 Accepted Submission(s): 962 Problem Description There are n cities in M^3's empire. M^3 owns a palace and a car and the palace resides in city 1. One day, she wants to travel around all the cities from her palace and finally back to her home. However, her car has limited energy and can only travel by no more than D meters. Before it was run out of energy, it should be charged in some oil station. Under M^3's despotic power, the judge is forced to build several oil stations in some of the cities. The judge must build an oil station in city 1 and building other oil stations is up to his choice as long as M^3 can successfully travel around all the cities. Building an oil station in city i will cost 2i-1 MMMB. Please help the judge calculate out the minimum cost to build the oil stations in order to fulfill M^3's will. Input There are several test cases (no more than 50), each case begin with two integer N, D (the number of cities and the maximum distance the car can run after charged, 0 < N ¡Ü 128). Then follows N lines and line i will contain two numbers x, y(0 ¡Ü x, y ¡Ü 1000), indicating the coordinate of city i. The distance between city i and city j will be ceil(sqrt((xi - xj)2 + (yi - yj)2)). (ceil means rounding the number up, e.g. ceil(4.1) = 5) Output For each case, output the minimum cost to build the oil stations in the binary form without leading zeros. If it's impossible to visit all the cities even after all oil stations are build, output -1 instead. Sample Input
Sample Output
Hint In case 1, the judge should select (0, 0) and (0, 3) as the oil station which result in the visiting route: 1->3->2->3->1. And the cost is 2^(1-1) + 2^(2-1) = 3. Source | ||||||||||
|