博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
(状压) Marriage Ceremonies (lightOJ 1011)
阅读量:6323 次
发布时间:2019-06-22

本文共 2076 字,大约阅读时间需要 6 分钟。

 

You work in a company which organizes marriages. Marriages are not that easy to be made, so, the job is quite hard for you.

The job gets more difficult when people come here and give their bio-data with their preference about opposite gender. Some give priorities to family background, some give priorities to education, etc.

Now your company is in a danger and you want to save your company from this financial crisis by arranging as much marriages as possible. So, you collect N bio-data of men and N bio-data of women. After analyzing quite a lot you calculated the priority index of each pair of men and women.

Finally you want to arrange N marriage ceremonies, such that the total priority index is maximized. Remember that each man should be paired with a woman and only monogamous families should be formed.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case contains an integer N (1 ≤ n ≤ 16), denoting the number of men or women. Each of the next N lines will contain N integers each. The jth integer in the ith line denotes the priority index between the ith man and jth woman. All the integers will be positive and not greater than 10000.

Output

For each case, print the case number and the maximum possible priority index after all the marriages have been arranged.

Sample Input

Output for Sample Input

2

2

1 5

2 1

3

1 2 3

6 5 4

8 1 2

Case 1: 7

Case 2: 16

 
题目大意:
 
公司组织婚礼, 有 n 个男生和 n 个女生匹配, 不同的人匹配会有不同的匹配值, 求最大的匹配值
 
dp[i][j] i代表前i个人,j 包含了将要匹配的所有状态(0为未匹配,1为已经匹配)
 
#include 
#include
#include
#include
#include
using namespace std;#define N 1100#define met(a,b) (memset(a,b,sizeof(a)))typedef long long LL;int a[20][20], dp[20][(1<<17)];int main(){ int T, iCase=1; scanf("%d", &T); while(T--) { int n, i, j, k, K; scanf("%d", &n); for(i=1; i<=n; i++) for(j=1; j<=n; j++) scanf("%d", &a[i][j]); K = (1<

 

转载于:https://www.cnblogs.com/YY56/p/5528251.html

你可能感兴趣的文章
使用 Kafka 和 MongoDB 进行 Go 异步处理
查看>>
禁止自动横屏下的视频播放强制旋转
查看>>
JavaScript实现链表
查看>>
103. Binary Tree Zigzag Level Order Traversal
查看>>
JavaScript函数式编程,真香之组合(一)
查看>>
使用Envoy 作Sidecar Proxy的微服务模式-3.分布式追踪
查看>>
深入了解以太坊
查看>>
SpringBoot 实战 (二) | 第一个 SpringBoot 工程详解
查看>>
Go goroutine理解
查看>>
IDE 插件新版本发布,开发效率 “biu” 起来了
查看>>
理解环境变量 JAVA_TOOL_OPTIONS
查看>>
看大牛是如何使用和理解线程池
查看>>
sql server 索引阐述系列八 统计信息
查看>>
c# Request对象(13)
查看>>
USB,蓝牙,以太网,还是WIFI?
查看>>
阿里云服务器更改时区为utc
查看>>
APP测试流程和测试点
查看>>
ansible实战
查看>>
PowerShell 远程管理之启用和执行命令
查看>>
mysql安装错误
查看>>