正在加载图片...
Problem d Ri ngs n Roi Time Limit: 3 seconds Well that seems to be the situation But I don'twant that, and you don' t want that and Ringo here definitely doesn t want that Jules Winnfield I have n tiny rings made of steel. I also have m pieces of rope, all of exactly the same length. The two ends of each piece of rope are tied to two different rings I am going to take one of the rings, L, into my left hand, and another ring, R into my right hand. Then I will pull the whole structure apart as hard as I can. Some of the ropes will be streched horizontally because of this. Others will hang down or bend out of shape. If I want the number of horizontally stretched ropes to be as large as possible, which l and R should I pick? Assume that the stretching of ropes in negligible, they all have negligible thickness and are free to slide around the rings that they are tied to. The thickness and radius of each ring is negligible, too Input The first line of input gives the number of cases, N. n test cases follow Each one starts with two lines containing n(2<=n<=120)and m (0<=m<=n(n-1)/2). The next m lines will each contain a pair of different [0,n-1]) connected by at most one rope Output For each test case, output the line containing Case #x:, followed by the largest number of ropes that I can stretch horizontally by pickin a pair of rings, L and r S ple inp Sample output7 Problem D Rings'n'Ropes Time Limit: 3 seconds "Well, that seems to be the situation. But, I don't want that, and you don't want that, and Ringo here definitely doesn't want that." Jules Winnfield I have n tiny rings made of steel. I also have m pieces of rope, all of exactly the same length. The two ends of each piece of rope are tied to two different rings. I am going to take one of the rings, L, into my left hand, and another ring, R into my right hand. Then I will pull the whole structure apart as hard as I can. Some of the ropes will be streched horizontally because of this. Others will hang down or bend out of shape. If I want the number of horizontally stretched ropes to be as large as possible, which L and R should I pick? Assume that the stretching of ropes in negligible, they all have negligible thickness and are free to slide around the rings that they are tied to. The thickness and radius of each ring is negligible, too. Input The first line of input gives the number of cases, N. N test cases follow. Each one starts with two lines containing n (2<=n<=120) and m (0<=m<=n(n-1)/2). The next m lines will each contain a pair of different rings (integers in the range [0, n-1]). Each pair of rings will be connected by at most one rope. Output For each test case, output the line containing "Case #x:", followed by the largest number of ropes that I can stretch horizontally by picking a pair of rings, L and R. Sample Input Sample Output 4 Case #1: 1
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有