HDU 3523 Image copy detection(KM)
来源:互联网 发布:关于在义乌外贸数据 编辑:程序博客网 时间:2024/06/06 10:24
#include<iostream>using namespace std;const int maxn=100+5;int w[maxn][maxn],n,m;int lx[maxn],ly[maxn];int Left[maxn];bool s[maxn],t[maxn];int a[maxn][maxn];bool match(int i){ s[i]=true; for(int j=1;j<=n;j++) if(lx[i]+ly[j]==w[i][j]&&!t[j]){ t[j]=true; if(!Left[j]||match(Left[j])){ Left[j]=i; return true; } } return false;}void update(){ int a=(1<<30); for(int i=1;i<=n;i++) if(s[i]) for(int j=1;j<=n;j++) if(!t[j]) a=min(a,lx[i]+ly[j]-w[i][j]); for(int i=1;i<=n;i++){ if(s[i]) lx[i]-=a; if(t[i]) ly[i]+=a; }}void KM(){ for(int i=1;i<=n;i++){ Left[i]=lx[i]=ly[i]=0; for(int j=1;j<=n;j++) lx[i]=max(lx[i],w[i][j]); } for(int i=1;i<=n;i++){ for(;;) { for(int j=1;j<=n;j++) s[j]=t[j]=0; if(match(i)) break;else update(); } }}int main(){ int T; scanf("%d",&T); for(int i=1;i<=T;i++) { scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) scanf("%d",&a[i][j]); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { w[i][j]=0; for(int k=1;k<=m;k++) w[i][j]-=abs(a[k][i]-j); } KM(); int ans=0; for(int i=1;i<=n;i++) ans+=w[Left[i]][i]; printf("Case #%d: %d\n",i,-ans); } return 0;}
0 0
- HDU 3523 Image copy detection KM算法
- HDU 3523 Image copy detection(KM)
- HDU 3523 Image copy detection(KM最大匹配)
- 【KM匹配】 HDOJ 3523 Image copy detection
- HDU 3523 Image copy detection & POJ 2516
- HDU 3523 Image copy detection 最小带权匹配
- [HDOJ 3523][Vjudge 10890] Image copy detection [费用流]
- HDU3523 Image copy detection 最小权匹配KM 2010 ACM-ICPC Multi-University Training Contest(9)——Host by HNU
- Image detection
- HDU 3523 最小费用流或KM
- Near Duplicate Image Detection
- image object detection
- emgucv copy image
- java copy image
- itk copy a image
- [matlab]copy image
- HDU 3718 KM
- HDU 2255 KM算法
- mac Navicat破解安装
- [笔记]《Linux内核设计与实现》第五章系统调用
- c++primer plus 第4章编程练习之路
- HBase设计与开发性能优化
- 继承
- HDU 3523 Image copy detection(KM)
- Espresso 自动化测试的使用
- TCP的交互数据流和成块数据流
- Matlab subs函数的用法
- Espresso IdlingResource 测试延时操作的使用
- 从老董身上学到的
- 速卖通如何快速挖掘关键词和查询商品的排名
- 微信小程序挑战APP胜算多少 要打谁的饭碗?
- web 列表切换