8649: Conquest of Masters Tour

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

The Hearthstone Masters Tour is a tournament for the famous card-collecting game Hearthstone, consisting of live and online events hosted every year in which Masters Qualifiers winners, Hearthstone Grandmasters, and other invitees compete for massive prize money.

In the Hearthstone Masters Tour, players are paired to play against each other in the format of Conquest, which is also the main match format used in official Hearthstone tournaments. The rule of the format is described as follows.

  1. Each player brings a specific number of decks, depending on tournament rules.
  2. To begin playing a round, each player chooses one of their decks to battle the opponent with, with the deck choice hidden from the opponent. The decks chosen by each player must satisfy the following rules:
    1. Any deck that wins a game cannot be played again in the match;
    2. Any deck that is defeated may be played again in the subsequent games.
    Then a game is played by the two players using the chosen deck.
  3. The first player to win with all of their decks wins the match.

Now you are playing a match in some Hearthstone Masters Tour where each player brings n decks and the decks are determined. You are given an n by n matrix A where Ai,jdenotes the probability of winning a game if you choose the i-th deck and your opponent chooses the j-th deck.

You want to know, what is the maximum probability you will win the match, supposing your opponent knows your strategy and chooses the deck optimally in each round.

输入格式

The first line contains an integer T, denoting the number of test cases. (1T5).

For each test case, the first line contains an integer n(1n8), denoting the number of decks each player brings.

Then nn lines describing the matrix AA follow, where the i(1in)-th line contains nnumbers with at most two decimal places Ai,1,Ai,2,,Ai,n(0Ai,j1).

输出格式

For each test case, output a number in one line, denoting the answer. Your answer is considered correct, if its absolute or relative error does not exceed 106.

Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if abmin(1,b)106.

输入样例 复制

3
1
0.50
3
1.00 1.00 1.00
1.00 1.00 1.00
0.00 0.00 0.00
3
1.00 0.00 0.00
0.00 1.00 0.00
0.00 0.00 1.00

输出样例 复制

0.5000000000
0.0000000000
0.1666666667