当前位置:网站首页>POJ2446 Chessboard【二分图最大匹配】
POJ2446 Chessboard【二分图最大匹配】
2022-07-27 12:34:00 【51CTO】
题目链接:
http://poj.org/problem?id=2446
题目大意:
给一个N*M的矩阵,其中有K个地方有坑。告诉你这K个坑的位置,现在要用1*2的矩形板去覆盖
矩阵,不能覆盖有坑的地方。问:是否能把除了坑之外的地方全部覆盖掉,如果能,则输出"YES",
否则输出"NO"。
思路:
考虑到矩形板的规格是1*2,则相邻位置的(i,j)和(x,y)必然是(i+j)为奇数的话,(x+y)则为偶数。
(i+j)为偶数的话,(x+j)则为奇数。这样,就可以把图上的所有点分为横纵坐标相加为奇数的点和
横纵坐标相加为偶数的点。然后建立一个二分图,一边为奇数点,另一边为偶数点。如果能用矩
形板覆盖(即没有坑),则在二分图上加边。然后求出二分图最大匹配ans,也就是最多能覆盖多少
矩形板。因为每个矩形板的规格是1*2,所以要判断是否能把除了坑之外的全部地方覆盖掉,只需
要判断ans*2 + K 是否等于M*N即可。
AC代码:
边栏推荐
- 为什么需要外键?
- js真伪数组转换
- POJ1273 Drainage Ditches【最大流】【SAP】
- 爬虫
- Complete data summary of lapsus$apt organization that stole Microsoft's source code in March 2022
- Overview of famous inner classes and anonymous inner classes
- 文章复现:SRCNN
- (07) flask is OK if you have a hand -- flask Sqlalchemy
- 20210419 combined sum
- Top 10 international NFT exchanges
猜你喜欢
随机推荐
Julia beginner tutorial 2022
Map interface
US pressure surges tiktok changes global safety director
概述有名内部类与匿名内部类
多表查询
2021-03-15
The strongest distributed locking tool: redisson
Security measures for tcp/ip protocol vulnerabilities
Aike AI frontier promotion (7.27)
如何获取Class类对象
内涵语录
What should I do if I can't see any tiles on SAP Fiori launchpad?
@Postconstruct annotations and initializingbean perform some initialization operations after bean instantiation
Common usage of curl command
Enjoy the luxury meta universe louis:the game, and participate in the NFT series digital collection white roll activity | tutorial
An overview of kernel compilation system
BSP视频教程第21期:轻松一键实现串口DMA不定长收发,支持裸机和RTOS,含MDK和IAR两种玩法,比STM32CubeMX还方便(2022-07-24)
HDU1698_ Just a Hook
ArrayList常用方法总结
关于 CMS 垃圾回收器,你真的懂了吗?








