编程介的小学生 2017-03-31 06:05 采纳率: 0.4%
浏览 791
已采纳

Ropes

Little Danny has a board with pillars distributed in a matrix. Each pillar has the radius of 1 unit, and is 4 units apart from its neighboring pillars. Danny uses ropes to wrap pairs of adjacent pillars, and fills the area enclosed by the ropes with color. When everything is removed Danny is amazed by the patterns. As a little math-mania, he begins to calculate the area and perimeter of the patterns. As there are pretty much work to process, he could make mistakes here and there. As a friend you want to remind him that computers are always more reliable than human minds, and thus created this program.

You will be given the coordinates of the pair of pillars. Danny's board has a maximal of 26 rows and columns. The rows are denotes by lower case letters and the columns denoted by numbers.

Input

Input contains multiple test cases. Each test case starts with N - the number of ropes on a single line (0 < N <= 1300). A test case with N = 0 terminates the input and this case should not be processed.

The next N lines contain a rope configuration each, with the coordinates of the two pillars separated by exactly one space. You can assume the two pillars will always be adjacent.

Output

Print the maximum area and perimeter of the patterns on a single line, separated by exactly one space. Three digits after the decimal point is required.

Sample Input

1
a1 b1
4
a1 b1
b1 b2
b2 a2
a2 a1
0

Sample Output

11.142 14.283
31.142 22.283

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-04-09 15:34
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?