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集合中 然后就是构建二部图 关键就是构图 然 ...
随机推荐
- BZOJ 2244 [SDOI2011]拦截导弹 (三维偏序CDQ+线段树)
题目大意: 洛谷传送门 不愧为SDOI的duliu题 第一问?二元组的最长不上升子序列长度?裸的三维偏序问题,直接上$CDQ$ 由于是不上升,需要查询某一范围的最大值,并不是前缀最大值,建议用线段树实 ...
- Layui表格编辑【不依赖Layui的动态table加载】
依赖jquer,layui/css <td class="My_edit"></td> Jquery代码 //-----[Layui表格编辑(<td ...
- Android开发进度03
1,今日:目标:实现登录界面 2,昨天:实现第一个Android项目Helloworld 3,收获:会使用手机进行测试,会使用SQlite数据库 4,问题:创建项目时出错
- C#调用带结构体指针的C Dll的方法【转】
发现一篇文章关于C#调用DALL动态链接库的函数的,复制下来学习用.感谢作者的分析,原文传送门:https://www.cnblogs.com/ye-ming/p/8004314.html 在C#中调 ...
- HDU——T 1498 50 years, 50 colors
http://acm.hdu.edu.cn/showproblem.php?pid=1498 Time Limit: 2000/1000 MS (Java/Others) Memory Limi ...
- window8.1 CenterOS 双系统
window8.1 CenterOS 双系统 学习了: http://blog.csdn.net/ac_hell/article/details/53436890 https://jingyan.ba ...
- web前端project师知识汇总
分类: Web开发应用 一.何为Web前端project师? 前端project师,也叫Web前端开发project师.他是随着web发展.细分出来的行业.Web前端开发proj ...
- js判断是对象还是集合
/*============================================ 函数功能:对返回数据中的列表数据进行非空处理 ============================== ...
- [jzoj NOIP2018模拟11.02]
嗯T1忘记取模了,100到20 嗯T2忘记了那啥定理,暴力也写炸了,这题我认 嗯T3线段树合并分裂没有写炸,考场上就知道妥妥的70分.但是,分数出的时候听到有人说暴力也是70分,我???脸黑,枉我敲了 ...
- 【DNN】 安装问题
http://blog.csdn.net/hwt0101/article/details/9153083 这是IIS 注册的问题 IIS 在安装VS 之前就装上了,所以 没有注册是上 F4 从新卸载 ...