Carl the Ant的翻译

这是ACM上的一道题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2712 网址上可以提交。

 

Carl the Ant
Ants leave small chemical trails on the ground in order to mark paths for other ants to follow.Ordinarily these trails follow rather straight lines. But in one ant colony there is an ant named Carl, and Carl is not an ordinary ant. Carl will often zigzag for no apparent reason, sometimes crossing his own path numerous times in the process. When other ants come to an intersection, they always follow the path with the strongest scent, which is the most recent path that leads away from the intersection point.
蚂蚁为了让其它的同伴能够追踪到它们总会在自己走过的路上留下化学物质作为标记。通常这些标记都是直线的。但是在一群蚂蚁当中有一只名叫卡尔,卡尔可不是一只普通的蚂蚁。卡尔经常无故地走曲曲折折的路线,有时在行走的过程中甚至会横穿自己走过的路多次(像穿越十字路口那样)。当其它的蚂蚁来到十字路口,它们只会跟着气味强烈的那条路走,也就是那条最新标记出来的穿过十字路口的路。
Ants are 1 centimeter long, move and burrow at 1 centimeter per second, and follow their paths exactly (bending at right angles when moving around corners). Ants cannot cross or overlap each other. If two ants meet at the exact same instant at an intersection point, the one that has been on Carl's path the longest has the right of way; otherwise, the ant that has been waiting the longest at an intersection will move first.
蚂蚁体长1厘米。无论是移动还是打洞,都是每秒前进1厘米,而且能很精确地追随前蚂蚁的足迹(到十字路口时总是能正确拐弯)蚂蚁们是不能穿过其它蚂蚁的身体或者从其它蚂蚁的背上翻过去的。如果两只蚂蚁碰巧在蚁海茫茫中相遇,没有早一步,也没有晚一步,而且就在撞在那个十字路口了。追随卡尔时间更早的那只蚂蚁有权先走,除此之外,在十字路等得更久的也可以先走。
Carl burrows up from the ground to start at the origin at time 0. He then walks his path and burrows back down into the ground at the endpoint. The rest of the ants follow at regular intervals. Given the description of Carl's path and when the other ants start the path, you are to determine how long it takes the entire set of ants to finish burrowing back into the ground. All the ants are guaranteed to finish.
 卡尔钻出地面上看到第一缕阳光的时间是0时刻。记住,出洞的地方是起点!随后,它在外面信步由缰地走走,想回洞就直接挖进去就行了。进去的那个点就是终点。剩下的蚂蚁就每隔一段时间出来一只,跟着他晒太阳。已经给出的是卡尔的路径和其它蚂蚁出洞的时刻。你需要算出整个蚁群从第一只出来到全部回洞用了多长时间。要保证所有的蚂蚁都回洞了哦,一个都不能少。
Input
Input consists of several test cases. The first line of the input file contains a single integer indicating the number of test cases.
输入由多个案例组成。第一行就一个整数表示测试案例的个数。
The input for each test case starts with a single line containing three positive integers n (1 <= n <= 50), m (1 <= m <= 100), and d (1 <= d <= 100). Here, n is the number of line segments in Carl's path, m is the number of ants traveling the path (including Carl), and d is the time delay before each successive ant's emergence. Carl (who is numbered 0) starts at time 0. The next ant (ant number 1) will emerge at time d, the next at time 2d, and so on. If the burrow is blocked, the ants will emerge as soon as possible in the correct order.
每个案例输入的第一行有三个正数n (1 <= n <= 50), m (1 <= m <= 100),和d (1 <= d <= 100).在这里,n代表卡尔走过的路径有多少个路段。m代表所有出来晒太阳的蚂蚁(当然卡尔也是其中的一份子)。d代表连续出洞的蚂蚁的时间间隔。卡尔是0号,当然也是在0时刻出来。下只蚂蚁标号为1,在时刻d出现,下下只当然出现在2d时刻喽!以此类推。如果洞被堵住了,蚂蚁会尽快按正确的顺序出现。
Each of the next n lines for the test case consists of a unique integer pair x y (-100 <= x, y <= 100), which is the endpoint of a line segment of Carl's path, in the order that Carl travels. The first line starts at the origin (0,0) and the starting point of every subsequent line is the endpoint of the previous line.
对于每个案例,随后有n行输入。每行有两个整数x y (-100 <= x, y <= 100)他们代表着卡尔所走的每段路的终点。(其实就是拐弯处)这些点都是按卡尔行走的顺序出现的。第一行以原点(0,0)开始,而且下一段路的开始点同时也是上一段路的终结点。
For simplicity, Carl always travels on line segments parallel to the axes, and no endpoints lie on any segment other than the ones which they serve as an endpoint.
 为了简化问题(已经够难了,还简化个球啊!)卡尔总是沿着平行与坐标轴线路行走。而且,除了那个被认为是终点的路径以外,并没有其它的路段的终点可以终结卡尔的晒太阳过程。(这里我也有点乱了……)
Output
The output for each case is described as follows:
输出的描述如下:
Case C:
Carl finished the path at time t 1 The ants finished in the following order:
a 1 a 2 a 3 ... a m The last ant finished the path at time t 2
 Here, C is the case number (starting at 1), a 1 a 2 a 3 ... a m are the ant numbers in the order that they go back underground, and t 1 and t 2 are the times (in seconds) at which Carl and the last ant finish going underground. You should separate consecutive cases with a single blank line.
在这里,C代表案例号(从1开始)a 1 a 2 a 3 ... a m   是蚂蚁们的编号,按他们回洞的顺序。
t 1 和t 2  是卡尔和最后一只回洞的蚂蚁所在的时刻。(以秒作为计量单位)
对于这些连续案例你需要用一个空行来区分。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值