Color Tunnels(翻译)

2022.2.12

题目网址:

http://noi.openjudge.cn/ch0206/687/

原题:

Color Tunnels

总时间限制: 

1000ms

内存限制: 

65536kB

描述

A company producing toys has a complex system to paint its products. To obtain the desired color, the product must be painted by several colors in a specified order. A product is painted by moving through color tunnels. For each color there is at least one tunnel that paints with that color, but there may be more. The tunnels are distributed in the painting area and the product must be delivered from one tunnel to another in order to be painted with the given colors. The product is at a certain point in the production plant when painting process starts and must finally be delivered to the product warehouse.

More formally, a finished uncolored product is at a certain given point (source point) and must be delivered to another given point (destination point) after being painted with different colors in a given order. There are several tunnels, each is assumed to be a line segment in the plain with a specific color. The colors of the tunnels are not necessarily distinct. Let < c1, c2, ..., cn > be the sequence of n colors that the product is to be painted with. The product is required to pass through tunnels < t1, t2, ... tn > such that the color of ti is ci. Note that it is possible to pass through a tunnel without being painted, so the mentioned < t1, t2, ... tn > may be in fact a subsequence of the tunnels which the product passes through. The direction in which the product passes a tunnel is not important. The goal is to find the shortest path from source to destination subject to the color constraints. The path may cross itself, or even cross a tunnel. Passing twice (or more) through a tunnel is also allowed. Note that two tunnels can cross or overlap but are different.

输入

The input file contains several test cases. The first line of the input consists of a single integer t (between 1 and 20), the number of test cases. Following the first line is the data for t test cases. The first line of each test case contains four real numbers xs, ys, xt, yt which are x and y coordinates of the source and destination respectively. The second line of the test case contains the color sequence: the first number is the length of the sequence (between 1 and 30), and the rest of the line is the sequence itself. Each color in the sequence is an integer in the range 1...100. The third line contains a single integer n in the range 1...60 which is the number of tunnels followed by n lines each containing five numbers. The first two numbers are the x and y coordinates of one end of the tunnel. The third and fourth numbers are the x and y coordinates of the other end. Coordinates are real numbers. The fifth number is an integer in the range 1...100

输出

The output file must have t lines, each containing the minimum length of a path from source to destination subject to the constraints of the problem. The length will be compared to optimal length within a precision of three digits after decimal point.

翻译:

描述:

一个生产玩具的公司有一个用来画他们的产品的复杂的系统。为了获得所期望的颜色,产品必须以一个特定的次序用几种颜色画。一个产品通过颜色隧道被移动。对于每种颜色至少一个隧道是画那种颜色的,但是可能这个隧道画更多的颜色。这些隧道被分配在画画区域并且为了被画上被给的颜色,产品必须从一个隧道被运送到另一个隧道。当画画处理开始并且最后必须被运送到产品仓库时,产品在一个生产工厂的特定的一个点。

更正式的来说,一个完成的没有着色的产品在一个特定的被给定的点(原点)并且在被以一定的次序画上不同的颜色之后必须被运送到另一个被给定的点(目标点)。这里有几个隧道,每个都被假定为有一个特定颜色的平原上的一部分。这些隧道的颜色不一定是不同的。让<c1,c2,...,cn>成为要画在产品上的这n种颜色的次序。产品需要穿过隧道<t1,t2,...,tn>以便于隧道ti的颜色是ci。注意也可能通过一个隧道的,但是没有被画,所以被提到的<t1,t2,...,tn>隧道可能事实上是产品通过的一个子隧道。产品通过一个隧道的方向不重要。目的是找到从原点到目标点的最短的路径,以题目的约束条件。路径可能穿过它自己,或者甚至穿过一条隧道。穿过第二次(或者更多)同一条隧道也是被允许的。注意两条隧道都能互相穿过或者重叠,但是它们仍然是不同的。

输入:

输入数据包含几组测试样例。输入的第一行包含单个的整数t(在1到20之间),是测试样例的数量。接下来第一行是测试样例的数据。每组测试样例的第一行包含4个实数xs,ys,xt,yt,其中的两组x,y分别是原点坐标和目标点坐标。测试样例的第二行包含颜色的次序:第一个数字是这个次序的长度(在1到30之间),这一行剩下的是这个次序本身。这个次序的每种颜色是一个取值1到100之间的整数。第三行包含单个取值在1到60之间的整数n,表示隧道的数量,后面n行每行包含5个数字。前面的两个数字是隧道一端的x和y坐标。第三和第四个数字是隧道另一端的x和y坐标。坐标都是实数。第五个数字是一个取值1到100之间的整数。

输出:

输出数据有t行,每行包含一条从原点到目标点的路径的最小长度,以这个问题的约束条件。该长度将在小数点后三位精度范围内与最佳长度进行比较。

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值