#P2269. [HNOI2002] 高质量的数据传输

[HNOI2002] 高质量的数据传输

Description

Original statement (image):

To support various QoS requirements, modern networks consider parameters such as path delay, bandwidth, delay jitter, and loss rate when selecting routes. In a certain high-quality data transmission project, only two parameters are considered: network delay and loss rate.

The network can be represented by a simple undirected graph G=(V,E)G = (V, E), where VV is the set of nodes in the network and EE is the set of links (edges) between pairs of nodes. According to the project requirements, each edge has two parameters: latency and loss rate.

  • The latency tt on an edge is the time required for data to travel from one endpoint to the other. It is an integer measured in milliseconds, with 0t1000 \le t \le 100.
  • The loss rate pp of an edge is the percentage of data lost after transmission from one endpoint to the other, with 0p0.10 \le p \le 0.1.

Route selection on network GG is defined as follows: given two nodes uu and vv in GG, find a path between them.

For a path P=v1,v2,v3,,vnP = v_1, v_2, v_3, \dots, v_n in GG, suppose the latencies and loss rates of the edges on the path are

$$t_1, t_2, t_3, \dots, t_{n-1}, \quad p_1, p_2, p_3, \dots, p_{n-1}.$$

Then the total latency from v1v_1 to vnv_n is

i=1n1ti,\sum_{i=1}^{n-1} t_i,

and the total loss rate is

1i=1n1(1pi).1 - \prod_{i=1}^{n-1} (1 - p_i).

High-quality data transmission requirement: if data is to be transmitted from a node uu to another node vv, then among all paths from uu to vv, the chosen path must have the minimal loss rate; subject to this, the latency must be minimal.

Given two nodes in the network graph, find a path that satisfies the high-quality data transmission requirement.

Input Format

There are 2n+12n+1 lines.

  • Line 11: the number of nodes nn (1n2001 \le n \le 200) and the indices of the two nodes i,ji, j to transmit data between (1i,jn1 \le i, j \le n, iji \ne j).

  • Lines 22 to n+1n+1: the adjacency matrix of latencies tt. Each element tu,vt_{u,v} (1tu,v100-1 \le t_{u,v} \le 100, tu,v=tv,ut_{u,v} = t_{v,u}, tu,u=0t_{u,u} = 0) gives the latency of the edge from node uu to node vv. A value of 1-1 indicates that there is no edge between uu and vv.

  • Lines n+2n+2 to 2n+12n+1: the adjacency matrix of loss rates pp. Each element pu,vp_{u,v} gives the loss rate of the edge from node uu to node vv (up to 44 decimal places). A value of 1-1 indicates that there is no edge between uu and vv.

It is guaranteed that tu,v=1t_{u,v} = -1 if and only if pu,v=1p_{u,v} = -1.

It is guaranteed that pu,v{1}[0,0.1]p_{u,v} \in \{-1\} \cup [0, 0.1], pu,v=pv,up_{u,v} = p_{v,u}, and pu,u=0p_{u,u} = 0.

Output Format

Output 11 line containing the latency and the loss rate of the chosen path. The latency is an integer and should be printed directly; the loss rate is a real number printed to 44 decimal places.

3 1 3                       
0 1 5
1 0 2
5 2 0
0 0.1 0.05
0.1 0 0.05
0.05 0.05 0
5 0.0500

Hint

Translated by ChatGPT 5