HDU 4619 Warm up 2 最大匹配数

本文介绍了一种解决水平和垂直骨牌放置问题的算法,通过二分匹配找到最少移除骨牌的数量,使得剩余骨牌不重叠。提供了一个完整的C++实现案例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

点击打开链接

 

 

Warm up 2

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 967    Accepted Submission(s): 465


Problem Description
  Some 1×2 dominoes are placed on a plane. Each dominoe is placed either horizontally or vertically. It's guaranteed the dominoes in the same direction are not overlapped, but horizontal and vertical dominoes may overlap with each other. You task is to remove some dominoes, so that the remaining dominoes do not overlap with each other. Now, tell me the maximum number of dominoes left on the board.
 


 

Input
  There are multiple input cases.
  The first line of each case are 2 integers: n(1 <= n <= 1000), m(1 <= m <= 1000), indicating the number of horizontal and vertical dominoes.
Then n lines follow, each line contains 2 integers x (0 <= x <= 100) and y (0 <= y <= 100), indicating the position of a horizontal dominoe. The dominoe occupies the grids of (x, y) and (x + 1, y).
  Then m lines follow, each line contains 2 integers x (0 <= x <= 100) and y (0 <= y <= 100), indicating the position of a horizontal dominoe. The dominoe occupies the grids of (x, y) and (x, y + 1).
  Input ends with n = 0 and m = 0.
 


 

Output
  For each test case, output the maximum number of remaining dominoes in a line.
 


 

Sample Input
  
2 3 0 0 0 3 0 1 1 1 1 3 4 5 0 1 0 2 3 1 2 2 0 0 1 0 2 0 4 1 3 2 0 0
 


 

Sample Output
  
4 6
 


 

Source
 


 

Recommend
zhuyuanchen520

 

题意:有水平N张牌,竖直M张牌,同一方向的牌不会相交。水平的和垂直的可能会相交,求最少踢出去几张牌使剩下的牌都不相交。

二分匹配 最小点覆盖=最大匹配。

 

#include<stdio.h>
#include<string.h>
using namespace std;
int n,m;
int g[1007][1007],link[1007];
bool vis[1007];
struct node
{
    int x,y;
}h[1007],v[1007];
bool judge(int i,int j)
{
    //注释掉的也能判断是否重合
    /*if(h[i].x==v[j].x||h[i].x+1==v[j].x)
    {
        if(v[j].y==h[i].y||v[j].y+1==h[i].y)
        return true;
    }*/
    //判断是否重合
    if(h[i].x<=v[j].x&&v[j].x<=h[i].x+1)
    {
        if(v[j].y<=h[i].y&&h[i].y<=v[j].y+1)
        return true;
    }
    return false;
}
bool find(int i)
{
    for(int j=1;j<=m;j++)
    if(g[i][j]&&!vis[j])
    {
        vis[j]=true;
        if(link[j]==0||find(link[j]))
        {
            link[j]=i;
            return true;
        }
    }
    return false;
}
int main()
{
    while(scanf("%d%d",&n,&m),n|m)
    {
        int count=0;
        memset(g,0,sizeof(g));
        memset(link,0,sizeof(link));
        for(int i=1;i<=n;i++)
        scanf("%d%d",&h[i].x,&h[i].y);
        for(int i=1;i<=m;i++)
        scanf("%d%d",&v[i].x,&v[i].y);
        for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        if(judge(i,j))
        {
            g[i][j]=1;
        }
        for(int i=1;i<=n;i++)
        {
            memset(vis,false,sizeof(vis));
            if(find(i))
            count++;
        }
        printf("%d\n",n+m-count);
    }
    return 0;
}


 

内容概要:本文详细探讨了基于MATLAB/SIMULINK的多载波无线通信系统仿真及性能分析,重点研究了以OFDM为代表的多载波技术。文章首先介绍了OFDM的基本原理和系统组成,随后通过仿真平台分析了不同调制方式的抗干扰性能、信道估计算法对系统性能的影响以及同步技术的实现与分析。文中提供了详细的MATLAB代码实现,涵盖OFDM系统的基本仿真、信道估计算法比较、同步算法实现和不同调制方式的性能比较。此外,还讨论了信道特征、OFDM关键技术、信道估计、同步技术和系统级仿真架构,并提出了未来的改进方向,如深度学习增强、混合波形设计和硬件加速方案。; 适合人群:具备无线通信基础知识,尤其是对OFDM技术有一定了解的研究人员和技术人员;从事无线通信系统设计与开发的工程师;高校通信工程专业的高年级本科生和研究生。; 使用场景及目标:①理解OFDM系统的工作原理及其在多径信道环境下的性能表现;②掌握MATLAB/SIMULINK在无线通信系统仿真中的应用;③评估不同调制方式、信道估计算法和同步算法的优劣;④为实际OFDM系统的设计和优化提供理论依据和技术支持。; 其他说明:本文不仅提供了详细的理论分析,还附带了大量的MATLAB代码示例,便于读者动手实践。建议读者在学习过程中结合代码进行调试和实验,以加深对OFDM技术的理解。此外,文中还涉及了一些最新的研究方向和技术趋势,如AI增强和毫米波通信,为读者提供了更广阔的视野。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值