Oil Skimming HDU
来源:互联网 发布:北师大网络教育官网 编辑:程序博客网 时间:2024/06/14 14:26
Thanks to a certain "green" resources company, there is a new profitable industry of oil skimming. There are large slicks of crude oil floating in the Gulf of Mexico just waiting to be scooped up by enterprising oil barons. One such oil baron has a special plane that can skim the surface of the water collecting oil on the water's surface. However, each scoop covers a 10m by 20m rectangle (going either east/west or north/south). It also requires that the rectangle be completely covered in oil, otherwise the product is contaminated by pure ocean water and thus unprofitable! Given a map of an oil slick, the oil baron would like you to compute the maximum number of scoops that may be extracted. The map is an NxN grid where each cell represents a 10m square of water, and each cell is marked as either being covered in oil or pure water.
16.......##....##.......#.....##......
Case 1: 3
题意 :最多有多少##(横着竖着都行)
#include<cstdio>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>using namespace std;char mapp[660][660];int aa[660][660];int a[2000][2000];int v[2000];int p[2000];int k,n;int tmp;int dfs(int u){ for(int i=1;i<tmp;i++) { if(!v[i]&&a[u][i]) { v[i]=1; if(!p[i]||dfs(p[i])) { p[i]=u; return 1; } } } return 0;}int main(){ scanf("%d",&k); int kk=1; while(k--) { memset(aa,0,sizeof(aa)); memset(a,0,sizeof(a)); memset(p,0,sizeof(p)); scanf("%d",&n); tmp=1; for(int i=0;i<n;i++) { scanf("%s",mapp[i]); for(int j=0;j<n;j++) { if(mapp[i][j]=='#') aa[i][j]=tmp++; } } for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(mapp[i][j]!='#') continue; if(mapp[i-1][j]=='#') a[aa[i-1][j]][aa[i][j]]=1; if(mapp[i+1][j]=='#') a[aa[i+1][j]][aa[i][j]]=1; if(mapp[i][j-1]=='#') a[aa[i][j-1]][aa[i][j]]=1; if(mapp[i][j+1]=='#') a[aa[i][j+1]][aa[i][j]]=1; } } int sum=0; for(int i=1;i<tmp;i++) { memset(v,0,sizeof(v)); if(dfs(i)) sum++; } printf("Case %d: %d\n",kk++,sum/2); }}
阅读全文
0 0
- hdu 4185 Oil Skimming
- Oil Skimming HDU
- Oil Skimming HDU
- Oil Skimming HDU
- Oil Skimming HDU
- HDU 4185Oil Skimming 匈牙利
- hdu 4185Oil Skimming (二分匹配)
- hdu 4185 Oil Skimming (二分匹配)
- hdu 4185 Oil Skimming (最大匹配)
- hdu 4185 Oil Skimming(最大匹配)
- 【二分匹配】hdu 4185 Oil Skimming
- hdu 4185 Oil Skimming(最大匹配)
- HDU 4185 Oil Skimming 二分图匹配
- hdu 4185 (Oil Skimming) 奇偶匹配
- HDU 4185 — Oil Skimming 二分匹配
- hdu 4185 Oil Skimming 二分图匹配
- hdu 4185 Oil Skimming 【最大匹配】
- hdu 4185 Oil Skimming 二分匹配
- 阿里云服务器部署otter实现数据双A同步过程记录(4)
- bootstrap栅格式布局
- Android WebView使用本地字体
- python里使用正则表达式来替换匹配成功的组并限定替换的次数
- python学习笔记 turtle类使用
- Oil Skimming HDU
- 9-EMM Scenario and Eleven EMM Cases
- JS——OOP1(console.dir)
- pthread_join
- 包含min函数的栈
- 使用Openembedded定制嵌入式Linux镜像
- 关于微信精选留言点赞刷赞之公众号评论点赞及文章评论点赞软件使用方法
- addChild的时候报出invalid 'cobj' in function 'lua_cocos2dx_Node_addChild'的错误
- 阿里云服务器部署otter实现数据双A同步过程记录(5)