Under construction

Still being built. Things may change

Craziness

Time limit2sMemory limit512 MB

Summary
Given a symmetric matrix of pairwise and individual craziness values for n up to 20 relatives, find the non-empty subset whose invited pairs plus individual terms sum to the maximum.
Level

Medium6 of 10

Topics
Brute force, Bit manipulation, Math, Implementation
Solved
No attempts yet

Problem

When you ask anyone about their family after a major gathering (for any kind of holidays, say), they will typically tell you how crazy their family is.1 Somehow, years of knowing each other, and probably genetic similarity, mean that family members know exactly how to egg each other on or exasperate each other. Somehow, when put in the same room, a group of normal quiet people suddenly become insanely wild. Here, you will calculate which family members to invite to maximize the total craziness.

For each pair of family members i, j, you will be given a (positive or negative) number ci,jc_{i,j}, which is how much craziness this pair will contribute if both are invited. Negative numbers mean that this pair will actually calm things down. The goal is to find the non-empty (that is, at least one person must be invited) subset to invite to achieve maximum total craziness, which is the sum of crazinesses over all pairs of invited family members, plus the individual crazinesses of all guests.

1If you asked salmon why they swim up rivers for weeks, they'd probably tell you: "I can't miss that party. My salmon family is crazy, man!!!"

Input

The first line contains a number K≥1K \ge 1, the number of input data sets in the file. This is followed by KK data sets of the following form:

The first line of a data set contains the number 2≤n≤202 \le n \le 20 of relatives to choose from. This is followed by nn lines, each with nn doubles −1000.0≤ci,j≤1000.0-1000.0 \le c_{i,j} \le 1000.0. ci,jc_{i,j} is the craziness added when you invite both i and j. We promise you that ci,j=cj,ic_{i,j} = c_{j,i} for all i and j. ci,ic_{i,i} is the craziness that person i himself or herself contributes.

Output

For each data set, first output "Data Set x:" on a line by itself, where x is its number. Then output the maximum total craziness you can get by inviting a non-empty subset of these relatives, rounded to two decimals.

Examples1

  1. Example 1

    Input
    1
    5
    1 -2.1 1.5 -10.3 4.7
    -2.1 0 -8.1 2.3 5.0
    1.5 -8.1 1.5 1.0 0.5
    -10.3 2.3 1.0 -1 15.4
    4.7 5.0 0.5 15.4 -2
    
    Expected output
    Data Set 1:
    19.70