Universal Cup Judging System

Universal Cup

実行時間制限: 1.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓
統計

银河系中有 $n$ 个行星。一些无向隧道连接着这些行星。每对行星之间最多存在一条隧道。因此,这些隧道可以用一个 $n \times n$ 的矩阵 $W_{n \times n}$ 来描述。具体来说,连接行星 $i$ 和 $j$ 的隧道宽度为 $w_{i,j}$(如果行星 $i$ 和 $j$ 之间没有隧道,则 $w_{i,j} = 0$)。

现在,你想要在 $n$ 个行星之间分配总共 $1.0$ 单位的能量。假设分配给行星 $i$ 的能量为 $e_i$($e_i$ 为实数,且满足 $e_i \ge 0, \sum_{i=1}^n e_i = 1$),这些行星将产生 $E$ 的魔法值,其中 $E = \sum_{i=1}^n \sum_{j=i+1}^n e_i e_j w_{i,j}$。

请分配能量以最大化魔法值。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 10$)。

接下来的 $n$ 行,每行包含 $n$ 个整数。第 $i$ 行的第 $j$ 个整数为 $w_{i,j}$ ($0 \le w_{i,j} \le 1000$),表示矩阵 $W_{n \times n}$。

输出格式

输出一个实数作为答案。如果你的答案为 $A$,标准答案为 $B$,当且仅当 $\frac{|A-B|}{\max(|A|,1)} \le 10^{-6}$ 时,你的答案将被接受。

样例

输入 1

2
0 1
1 0

输出 1

0.250000

输入 2

3
0 2 1
2 0 2
1 2 0

输出 2

0.571429

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.