HDU——T 1507 Uncle Tom's Inherited Land*
http://acm.hdu.edu.cn/showproblem.php?pid=1507
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3671 Accepted Submission(s): 1554
Special Judge
Your uncle Tom wants to sell the inherited land, but local rules now regulate property sales. Your uncle has been informed that, at his great-great-uncle's request, a law has been passed which establishes that property can only be sold in rectangular lots the size of two squares of your uncle's property. Furthermore, ponds are not salable property.
Your uncle asked your help to determine the largest number of properties he could sell (the remaining squares will become recreational parks).
6
1 1
1 4
2 2
4 1
4 2
4 4
4 3
4
4 2
3 2
2 2
3 1
0 0
(1,2)--(1,3)
(2,1)--(3,1)
(2,3)--(3,3)
(2,4)--(3,4)
3
(1,1)--(2,1)
(1,2)--(1,3)
(2,3)--(3,3)
#include <cstring>
#include <cstdio> using namespace std; const int N();
int fx[]={,,-,};
int fy[]={,,,-};
bool lose[N][N];
int n,m,ans,sumvis;
int vis[N][N],match[N][N][]; bool find(int x,int y)
{
for(int xx,yy,i=;i<;i++)
{
xx=fx[i]+x;yy=fy[i]+y;
if(!lose[xx][yy]&&vis[xx][yy]!=sumvis)
{
vis[xx][yy]=sumvis;
if(!match[xx][yy][]||find(match[xx][yy][],match[xx][yy][]))
{
match[xx][yy][]=x;
match[xx][yy][]=y;
return true;
}
}
}
return false;
} inline void init()
{
ans=;
memset(vis,,sizeof(vis));
memset(lose,,sizeof(lose));
memset(match,,sizeof(match));
} int AC()
{
for(int t,x,y;scanf("%d%d",&n,&m)&&n&&m;init())
{
for(scanf("%d",&t);t--;)
scanf("%d%d",&x,&y),lose[x][y]=;
for(int i=;i<=n;i++) lose[i][]=lose[i][m+]=;
for(int i=;i<=m;i++) lose[][i]=lose[n+][i]=;
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
if((i+j)&&&!lose[i][j])
{
if(find(i,j)) ans++;
sumvis++;
}
printf("%d\n",ans);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
if(match[i][j][])
printf("(%d,%d)--(%d,%d)\n",i,j,match[i][j][],match[i][j][]);
printf("\n");
}
return ;
} int I_want_AC=AC();
int main(){;}
HDU——T 1507 Uncle Tom's Inherited Land*的更多相关文章
- HDU 1507 Uncle Tom's Inherited Land*(二分图匹配)
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- Hdu 1507 Uncle Tom's Inherited Land* 分类: Brush Mode 2014-07-30 09:28 112人阅读 评论(0) 收藏
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- HDU 1507 Uncle Tom's Inherited Land*(二分匹配,输出任意一组解)
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- HDU 1507 Uncle Tom's Inherited Land(最大匹配+分奇偶部分)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1507 题目大意:给你一张n*m大小的图,可以将白色正方形凑成1*2的长方形,问你最多可以凑出几块,并输 ...
- HDU 1507 Uncle Tom's Inherited Land*
题目大意:给你一个矩形,然后输入矩形里面池塘的坐标(不能放东西的地方),问可以放的地方中,最多可以放多少块1*2的长方形方块,并输出那些方块的位置. 题解:我们将所有未被覆盖的分为两种,即分为黑白格( ...
- hdu-----(1507)Uncle Tom's Inherited Land*(二分匹配)
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- Uncle Tom's Inherited Land*
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- XTU 二分图和网络流 练习题 B. Uncle Tom's Inherited Land*
B. Uncle Tom's Inherited Land* Time Limit: 1000ms Memory Limit: 32768KB 64-bit integer IO format: %I ...
- hdu1507 Uncle Tom's Inherited Land* 二分匹配
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1507 将i+j为奇数的构成x集合中 将i+j为偶数的构成y集合中 然后就是构建二部图 关键就是构图 然 ...
随机推荐
- 一些html5
---匿名函数(funcation(){}())---- 一.拖拽 draggable=ture-----A拖动元素上事件 1. 拖拽开始:ondragstart2. 拖拽中:ondrag3. 拖拽结 ...
- code-reading-notes--xml 解析
- Python字典嵌套
import copy menu = { "计算机科学与技术":{ "程序编程":{ "传统语言":{ "C++":&q ...
- React 中的 refs的应用
React Refs React 支持一种非常特殊的属性 Ref ,你可以用来绑定到 render() 输出的任何组件上. 这个特殊的属性允许你引用 render() 返回的相应的支撑实例( back ...
- LaTeX 表格指定宽度并居中
本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50532269 在绘制表格的时候,对于特 ...
- linux mint(Ubuntu、Debian) 18修改环境变量
修改环境变量 sudo gedit /etc/profile sudo gedit /etc/profile 在profile文件的末尾添加以下代码 export JAVA_HOME=/usr/lib ...
- PatentTips - Increasing turbo mode residency of a processor
BACKGROUND Many modern operating systems (OS's) use the Advanced Configuration and Power Interface ( ...
- oracle用户锁定
https://www.cnblogs.com/lostyue/archive/2011/12/06/2278063.html
- openssl之EVP系列之10---EVP_Sign系列函数介绍
openssl之EVP系列之10---EVP_Sign系列函数介绍 ---依据openssl doc/crypto/EVP_SignInit.pod翻译 (作者:DragonKing, ...
- easyui编辑器(kindeditor-4.1.10)
//1 重写kindedit -建一个js文件 easyui_kindeditor.js (function ($, K) { if (!K) throw " ...