The Good, the Bad and the Ugly

The Good, the Bad and the Ugly are going to have their famous three-way
duel. For each pair of gunmen X and Y, with X ≠ Y, we know the
independent probability that if X shoots at Y, X will hit and kill Y.
Otherwise, Y will remain unhurt.

Initially, the Good will shoot at the Bad, the Bad will shoot at the
Ugly, and the Ugly will shoot at the Good. This will happen
simultaneously, and as many times as needed, until at least one of the
gunmen dies. Afterwards, if two of them are still alive, they will shoot
at each other simultaneously and repeatedly until at least one of them
dies.

Given the six killing probabilities, what are the chances for each of
the gunmen to survive?

Input

Input begins with the number of cases t. Follow t matrices with 3 rows
and 3 columns of probabilities each, which correspond in order to the
Good, the Bad and the Ugly. For instance, the second number of the first
row is the probability that if the Good shoots at the Bad, the Bad will
immediately die. The main diagonal is all zeroes. The rest are real
numbers strictly larger than 0 and smaller than or equal to 1.

Output

For each case, print the surviving probability of the Good, the Bad and
the Ugly in this order, with four digits after the decimal point. The
input cases have no precision issues.

[image]

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:16:39.793Z

© Jutge.org, 2006–2026.
https://jutge.org
