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. /etc/fstab 文件详解 及 /etc/mtab

    /etc/fstab 文件解释 文件fstab包含了你的电脑上的存储设备及其文件系统的信息.它是决定一个硬盘(分区)被怎样使用或者说整合到整个系统中的唯一文件. 这个文件的全路径是/etc/fstab ...

  2. hdu1067-Gap(bfs+哈希)

    Let's play a card game called Gap. You have 28 cards labeled with two-digit numbers. The first digit ...

  3. 最小费用最大流模板 poj 2159 模板水题

    Going Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15944   Accepted: 8167 Descr ...

  4. SoupUI接口测试学习分享

    一.SoapUI的使用 我们主要用SoapUI的REST 测试功能来测试我们协议接口.RESTful是一种服务端API的规范,每个资源对应唯一的URI,然后用HTTP的POST.GET.PUT.DEL ...

  5. QT文件夹定位(网友提供)

    #ifndef FOLDERFINDER_H #define FOLDERFINDER_H#include <QDir>class FolderFinder{public:    QStr ...

  6. iOS更新之DFU模式和恢复模式

    DFU模式和恢复模式的区别:DFU模式是在iPhone固件引导启动之前进行恢复的模式.所以用DFU模式刷机一般比较干净,不会有任何垃圾文件.想当于电脑重新格式化之后再安装系统. DFU模式进入方法:1 ...

  7. 黑马程序员 Java正则表达式,详解反斜线在Java中的作用

    ---------------------- ASP.Net+Android+IO开发S. .Net培训.期待与您交流! ---------------------- 在程序设计过程中,经常需要对获取 ...

  8. SmaterWeatherApi---签名加密和数据訪问--简单粗暴一步搞定

    -----------------------------------------------------更新-2014-07-09---------------------------------- ...

  9. Android 打造自己的个性化应用(二):应用程序内置资源实现换肤功能

    通过应用程序内置资源实现换肤,典型的应用为QQ空间中换肤的实现. 应用场景为: 应用一般不大,且页面较少,风格相对简单,一般只用实现部分资源或者只用实现背景的更换. 此种换肤方式实现的思路: 1. 把 ...

  10. IoC容器Autofac之实例优化(三)

    回顾之前的代码 //这个类的作用是筛选出MPG类型的电影 public class MPGMovieLister { public Movie[] GetMPG() { var finder = Mo ...