题目

搜索 可行性剪枝

虽然这题目是我搜二分图的标签搜到的

但是n比较小

明显可以暴力

然而只有80分

再加上可行性剪纸就行啦

就是记所有运动员他所能匹配到的最大值、

在我们搜索到第i层的时候

如果他后边的运动员的最大值加起来还比当前已经搜到的最优解还小的话

就把他减掉

Code:

//bao li
#include <cstdio>
#include <iostream>
using namespace std;
const int N = ;
int n, a[N][N], b[N][N], maxn[N], ans;
bool vis[N];
int read() {
int s = , w = ;
char ch = getchar();
while(!isdigit(ch)) {if(ch == '-') w = -; ch = getchar();}
while(isdigit(ch)) {s = s * + ch - ''; ch = getchar();}
return s * w;
}
void dfs(int dep, int w) {
if(dep > n) {ans = max(ans, w); return;}
int sum = ;
for(int i = dep; i <= n; i++) sum += maxn[i];
if(w + sum < ans) return;
for(int i = ; i <= n; i++)
if(!vis[i]) {
vis[i] = ;
dfs(dep + , w + a[dep][i] * b[i][dep]);
vis[i] = ;
}
}
int main() {
n = read();
for(int i = ; i <= n; i++)
for(int j = ; j <= n; j++)
a[i][j] = read();
for(int i = ; i <= n; i++)
for(int j = ; j <= n; j++)
b[i][j] = read();
for(int i = ; i <= n; i++)
for(int j = ; j <= n; j++)
maxn[i] = max(maxn[i], a[i][j] * b[j][i]);
dfs(, );
cout << ans << endl;
return ;
}

谢谢收看, 祝身体健康!

洛谷p1559运动员最佳匹配问题的更多相关文章

  1. [洛谷 P1559] 运动员最佳匹配问题

    题目描述 羽毛球队有男女运动员各n人.给定2 个n×n矩阵P和Q.P[i][j]是男运动员i和女运动员j配对组成混合双打的男运动员竞赛优势:Q[i][j]是女运动员i和男运动员j配合的女运动员竞赛优势 ...

  2. P1559 运动员最佳匹配问题[最大费用最大流]

    题目描述 羽毛球队有男女运动员各n人.给定2 个n×n矩阵P和Q.P[i][j]是男运动员i和女运动员j配对组成混合双打的男运动员竞赛优势:Q[i][j]是女运动员i和男运动员j配合的女运动员竞赛优势 ...

  3. 【题解】P1559 运动员最佳匹配问题

    [题目](https://www.luogu.com.cn/problem/P1559) 题目描述 羽毛球队有男女运动员各n人.给定2 个n×n矩阵P和Q.P[i][j]是男运动员i和女运动员j配对组 ...

  4. P1559 运动员最佳匹配问题

    题目描述 羽毛球队有男女运动员各n人.给定2 个n×n矩阵P和Q.P[i][j]是男运动员i和女运动员j配对组成混合双打的男运动员竞赛优势:Q[i][j]是女运动员i和男运动员j配合的女运动员竞赛优势 ...

  5. KM模板 最大权匹配(广搜版) Luogu P1559 运动员最佳匹配问题

    KM板题: #include <bits/stdc++.h> using namespace std; inline void read(int &num) { char ch; ...

  6. P1559 运动员最佳匹配问题 by hyl 天梦

    #include<iostream> using namespace std; int n; int maxx[21][21]; int lie[21]; int aa[21]; int ...

  7. Luogu 1559 运动员最佳匹配问题(带权二分图最大匹配)

    Luogu 1559 运动员最佳匹配问题(带权二分图最大匹配) Description 羽毛球队有男女运动员各n人.给定2 个n×n矩阵P和Q.P[i][j]是男运动员i和女运动员j配对组成混合双打的 ...

  8. 运动员最佳匹配问题 KM算法:带权二分图匹配

    题面: 羽毛球队有男女运动员各n人.给定2 个n×n矩阵P和Q.P[i][j]是男运动员i和女运动员j配对组成混合双打的男运动员竞赛优势:Q[i][j]是女运动员i和男运动员j配合的女运动员竞赛优势. ...

  9. 运动员最佳匹配问题(km算法)

    洛谷传送门 带权二分图最大权完美匹配. 裸的km算法. 注意开long long. #include <cstdio> #include <cstring> #include ...

随机推荐

  1. 【More Effective C++ 条款1】仔细区别pointers和references

    1)操作符的差别 指针使用"*"和"->"操作符,而引用使用"."操作符 2)初始化的差别 有空指针,但是没有空引用,和const对象 ...

  2. 【LeetCode】145. Binary Tree Postorder Traversal

    Difficulty: Hard  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/binary-tree-pos ...

  3. Debian CentOS修改时区

    Debian修改时区: dpkg-reconfigure tzdata https://wiki.debian.org/TimeZoneChanges CentOS修改时区: timedatectl ...

  4. js计算两经纬度之间的距离

    js如下: // 方法定义 lat,lng function GetDistance( lat1, lng1, lat2, lng2){    var radLat1 = lat1*Math.PI / ...

  5. A - A Compatible Pair-biaobiao88

    A - A Compatible Pair Nian is a monster which lives deep in the oceans. Once a year, it shows up on ...

  6. 来看一下Java中“-”与equeals的区别

    简介: == ==是比较两个变量的值,如果是基本数据类型,那么就是比较的基本数据的大小值 情况一 int a=1; int b=1; System.out.println(a==b); 以上图中:== ...

  7. windows下搭建vue+webpack的开发环境

    1. 安装git其右键git bash here定位比cmd的命令行要准确,接下来的命令都是利用git bash here.2. 安装node.js一般利用vue创建项目是要搭配webpack项目构建 ...

  8. 结对项目(JAVA)

    项目成员: 邓镇港 3117004608 陈嘉欣 3117004604 一.Github项目地址: https://github.com/kestrelcjx/operation_expression ...

  9. yum无法下载,网关问题

    由于网关地址改变没有及时更新配置,造成无法下载 failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try h ...

  10. springmvc 整合 netty-socketio

    1 maven <dependency> <groupId>com.corundumstudio.socketio</groupId> <artifactId ...