Distance Over The World

After graduated from Nankai University, Mr. AngelClover and his classmates goes to different places all over the world. Now Mr. AngelClover has a project. In this project he needs to know the distance between the nearest two students who knows each other. For simplicity, he will describe the locations of classmates by 2-dimensional coordinates, and the distance measured by Euclid distance. For example, if Jack lives at (3, 5), and Alphard lives at (4, 6), the distance between them is .

However, some students don't know all the other students in our university. Luckily, the monitor knows the class number every student was in. Students who were in the same class know each other. The monitor also knows the courses which class has take. You can assume that students in the same class always take courses together and students can only know each other by taking the same classes together.

Now it's your mission to find out what Mr. AngelClover wants.

 

Input     (Please use standard input, and don’t read or write files.)

 

The first line of the input contains three integers N, M, C. N means the number of students, and M means the number of classes and C the number of courses. From the 2nd to the (C+1)th line, each line contains the course name, which is less than eighty letters and all is lower-case letters. An integer K following the course name means number of classes which have taken this course, then follows K numbers represent the classes' number. Then follows N line each line contains three integers Z, X, Y. This means a student who was in Class Z lives at (X, Y).

You are guaranteed that 0< N <=105, 0< M <=100, 0<= C <=100, 0<= K <=10, 0< Z <=M, |X|<109, |Y|<109.

 

Output   (Please use standard output, and don’t read or write files.)

 

Output only contains one real number represents the distance Mr. AngelClover wants.

You should output the answer with 6 digits after the decimal point.

You are guaranteed the answer always exists.

 

 

 

Sample Input

Sample Output

5 3 2

math 2 1 2

english 2 1 3

2 0 0

3 1 0

1 0 2

3 3 2

2 4 2

 

2.000000

Hint

The distance between 1st and 3rd students is 2.000000.

   

 

没有什么特别的算法。

一个邻接表记录每个课程所有的班级,并且把这些班级按班号从小到大排序。

然后对输入的同学,按班号从小到大排序。用一个数组记录每个班级的第一个同学的位置。

最后,遍历邻接表,根据邻接表一行的班号,对这些班里的同学两两求距离,得出最小的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值