The Most Wonderful Competition

Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others)
Submit Status

Last week, School of Applied Mathematics held a competition of flying kite, contestants are divided into pairs, and one contestant competes with another in each pair. As we know, different way dividing pairs may bring different splendid level value, which appears as a real numbers. Now Miss Ye wants to know how to divide the competitor in order to attain maximum splendid level.

Input

The first line of the input contains one integer T, which indicate the number of test case.

For each test case, in the first line there is an integer N (N≤16, N is always an even number) indicating there are N contestants taking part the competition.

In the next N line, each line contains N real numbers. The j-th number in the i-th line is the splendid level value when the i-th contestant and the j-th constant are made in one pair. You can assume the j-th number in the i-th line is equal to the i-th number in the j-th line.

Output

For each case, output the maximum total splendid level value accurate to two digits after the radix point.

Sample input and output

Sample Input Sample Output
1
2
0.0 1.0
1.0 0.0
1

Source

电子科技大学第七届ACM程序设计大赛 初赛
 
解题报告
简单集合DP,f(i)表示选择这i个元素时的最高加成
 
 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio> using namespace std;
const int maxn = + ;
double value[maxn][maxn];
double f[ << ];
bool arrive[<<];
int n;
double ans; double dfs(int cur,int val)
{
if (arrive[val])
return f[val];
arrive[val] = true;
double &ans = f[val] = -1e100;
if (val)
{
for(int i = ; i < n ; ++ i)
if (val >> i & && i != cur)
{
int next = ;
int newval = val;
newval &= ~( << i);
newval &= ~( << cur);
for(int j = ; j < n ; ++ j)
if (newval >> j & )
{
next = j;
break;
}
ans = max(ans,dfs(next,newval) + value[cur][i] );
}
}
else
ans = ;
return ans;
} int main(int argc,char *argv[])
{
int Case;
scanf("%d",&Case);
while(Case--)
{
memset(arrive,false,sizeof(arrive));
scanf("%d",&n);
for(int i = ; i < n ; ++ i)
for(int j = ; j < n ; ++ j)
scanf("%lf",&value[i][j]);
dfs(,(<<n)-);
printf("%.2lf\n",f[(<<n)-]);
}
return ;
}

UESTC_The Most Wonderful Competition CDOJ 56的更多相关文章

  1. Kaggle Competition Past Solutions

    Kaggle Competition Past Solutions We learn more from code, and from great code. Not necessarily alwa ...

  2. Gradient Boosting, Decision Trees and XGBoost with CUDA ——GPU加速5-6倍

    xgboost的可以参考:https://xgboost.readthedocs.io/en/latest/gpu/index.html 整体看加速5-6倍的样子. Gradient Boosting ...

  3. 1198 - Karate Competition

    1198 - Karate Competition    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...

  4. 编写高质量代码:改善Java程序的151个建议(第4章:字符串___建议56~59)

    建议56:自由选择字符串拼接方法 对一个字符串拼接有三种方法:加号.concat方法及StringBuilder(或StringBuffer ,由于StringBuffer的方法与StringBuil ...

  5. 推荐一个iOS关于颜色的库-Wonderful

    Wonderful 这个库主要是与UIColor息息相连的,其中一共包含四个子文件,UIColor+Wonderful,UIColor+Separate,SXColorGradientView,SXM ...

  6. ASProtect注册码使用教程|ASProtect SKE(加壳脱壳工具) 2.56 汉化注册版

    ASProtect 是功能非常完善的加壳.加密保护工具.能够在对软件加壳的同时进行各种保护.如:反调试跟踪.自校验及用密钥加密保护等:还有多种限制使用措施,如:使用天数限制.次数限制及对应的注册提醒信 ...

  7. 56相册视频(土豆相册视频 激动相册视频 QQ动感影集等)——下载教程

    由于目前流行的相册视频或影集大多是由Flash.音乐和图片组合而成的动画,不属于完整视频,所以不能用常规的解析方法下载. 鉴于很多朋友希望可以下载自己精心制作的相册,故在本教程中,我们将以图文并茂的方 ...

  8. cdoj 1489 老司机采花

    地址:http://acm.uestc.edu.cn/#/problem/show/1489 题目: 老司机采花 Time Limit: 3000/1000MS (Java/Others)     M ...

  9. A Regularized Competition Model for Question Diffi culty Estimation in Community Question Answering Services-20160520

    1.Information publication:EMNLP 2014 author:Jing Liu(在前一篇sigir基础上,拓展模型的论文) 2.What 衡量CQA中问题的困难程度,提出从两 ...

随机推荐

  1. sourceforge软件下载方式

    访问http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/ 根据软件名称在文件列表中查找

  2. 在wp中,使用NavigationService.Navigate导航页面出现错误

    我们在WP项目中采用页面导航时候,经常会使用以下代码 NavigationService.Navigate(new Uri("/Page1.xaml",UriKind.Relati ...

  3. Longest Consecutive Sequence 解答

    Question Given an unsorted array of integers, find the length of the longest consecutive elements se ...

  4. OS error set

    Failed to resolve/decode supposed IPv4 source addres Failed to resolve/decode supposed IPv4 source a ...

  5. Linux 块设备驱动 (一)

    1.块设备的I/O操作特点 字符设备与块设备的区别: 块设备只能以块为单位接受输入和返回输出,而字符设备则以字符为单位. 块设备对于I/O请求有对应的缓冲区,因此它们可以选择以什么顺序进行响应,字符设 ...

  6. input表单 radio对象的判断选择

    /*选择约见对象*/ var lenth=$('input[name="single"]').length; var len=0; $('input[name="sing ...

  7. WPF可视化控件打印

    Introduction While coding an application that displays a detailed report in a ScrollViewer, it was d ...

  8. wpf纯前台绑定

    <Window x:Class="Example1.MainWindow" ... xmlns:local="clr-namespace:Example1" ...

  9. 动态载入TreeView时让TreeView节点前显示加号

    解释下标题,我这里通过webservice获取数据并动态载入TreeView节点.那么某个节点展开前它是没有子节点的.那么它就不显示加号.这样会让用户误以为此节点不能展开.我是这样做的,每次创建节点a ...

  10. 如何利用 Bootstrap 进行快速 Web 开发

    原文出处: IBM developerworks 了解如何使用 Bootstrap 快速开发网站和 Web 应用程序(包括移动友好型应用程序).Bootstrap 以 LESS 项目为基础,由 Twi ...