#P5814. [CTSC2001] 终极情报网

[CTSC2001] 终极情报网

Problem Description

Before the final Normandy landing battle began, the Allied and German intelligence agencies fought an unprecedented intelligence war over the final landing location. In this intelligence war, the Allied tactic was to use double agents hidden inside the enemy to release fake landing information to the heads of the German intelligence agencies. Those agents who had already infiltrated behind enemy lines were all elites of the Allied intelligence department, loyal and reliable. However, how to choose suitable people, and the best way to transmit messages, so that the fake information could be delivered to the German commanders as quickly, safely, and accurately as possible, became the biggest problem troubling the Allied intelligence minister. He needs your help.

The minister provides the following operational data:

There are a total of NN of our best spies behind enemy lines, numbered 1,2,,N1,2,\cdots,N. Within the given operation time, any two people can make at most one point-to-point two-person contact. You will be given a table. The table provides the security level of a contact between any two spies ii and jj, represented by a real number Si,jS_{i,j} in [0,1][0,1]; and the maximum number of messages they can exchange in this contact, represented by a positive integer Mi,jM_{i,j} (if it is not mentioned in the table, then spies ii and jj do not contact directly). The channel for sending fake messages from the Allied headquarters to each spy is also not absolutely safe. We use a real number ASjAS_j in [0,1][0,1] to represent the security level of contact between the headquarters and spy jj, and AMjAM_j to represent the maximum number of messages that can be transmitted when the headquarters contacts spy jj. For spies that do not contact the headquarters directly, AMj=0AM_j = 0 (and the given ASjAS_j is meaningless). Of course, the process of delivering a fake message from a spy to the German intelligence officer’s desk is absolutely safe; that is, a spy either does not contact the German intelligence department directly, or the security level of that contact is 11 (completely reliable).

Now the intelligence department plans to “leak” KK fake messages to the Germans. The messages are first sent by the headquarters in one batch to some of the NN spies, then spread through their intelligence network, and finally delivered to the Germans by some of these NN spies. For a single message, the transmission is considered safe only if it passes safely through all intermediate steps and reaches the German intelligence department. Therefore, by the multiplication rule, its security level PP is the product of the security levels of every transmission of that message, from the headquarters through multiple transfers until it reaches the Germans. For the whole plan, it is successful only when all KK messages pass safely through the network and reach the Germans, with none raising suspicion. So the reliability of the plan is the product of the security levels of all messages. Obviously, the reliability depends on how these messages are transmitted in the network. You need a scheme that decides from whom to whom each message should be passed, so that the final reliability is maximized.

You can use a computer to find the most reliable message transmission plan.

Input Format

The input contains the Allied operational data table.

The first line contains two integers NN and KK, which are the total number of spies and the total number of messages in the plan.

The second line contains 2N2N numbers. The first NN numbers are real numbers AS1,AS2,,ASNAS_1,AS_2,\cdots,AS_N (in the range [0,1][0,1]). The next NN numbers are integers AM1,AM2,,AMNAM_1,AM_2,\cdots,AM_N.

The third line contains NN integers. The ii-th integer (i=1,2,,Ni = 1,2,\cdots,N) is 00 if spy ii does not contact the German intelligence department, and 11 if spy ii does.

Starting from the fourth line, each line contains 44 numbers in order: the positive integers ii and jj representing spy IDs, the security parameter Si,jS_{i,j} of the contact between spies ii and jj (a real number in [0,1][0,1]), and the maximum number of messages Mi,jM_{i,j} that can be transmitted between ii and jj (in each line, ii is less than jj).

The last line is -1 -1, which indicates the end of input.

Output Format

Output only one line. This line contains a real number PP, which is the reliability PP of the whole plan, rounded to 55 significant digits.

If the intelligence network cannot transmit KK messages to the Germans at all, then the plan reliability is 00.

(You may assume that if a plan exists, then its reliability is greater than 101210^{-12}.)

6 13
0.9 0.7 0.8 0 0 0 2 6 8 0 0 0
0 0 0 1 0 1
1 4 0.5 2
2 3 0.9 5
2 5 0.8 2
2 6 0.8 7
3 5 0.8 2
5 6 0.8 4
-1 -1

0.00021184

Hint

1N,K3001 \le N,K \le 300.

Translated by ChatGPT 5