poj 3620 Avoid The Lakes
来源:互联网 发布:linux 查看进程cpu 编辑:程序博客网 时间:2024/05/20 17:59
#include<iostream>#include<math.h>#include<cstring>using namespace std;char map[500][500];int n,m,k;int b[4][2]={ {1,0},{-1,0},{0,1},{0,-1} };int cnt;void dfs(int x,int y){int dx,dy;int i;for(i=0;i<4;i++){dx=x+b[i][0];dy=y+b[i][1];if(dx>=1&&dx<=n&&dy>=1&&dy<=m&&map[dx][dy]=='1'){map[dx][dy]='0';cnt++;dfs(dx,dy);//cnt--;}}return ;}int main(){int i,j;int mmax;//int cnt;int a,b; while(scanf("%d%d%d",&n,&m,&k)!=EOF) { for(i=1;i<=499;i++) for(j=1;j<=499;j++) map[i][j]='0'; for(i=1;i<=k;i++) { scanf("%d%d",&a,&b); map[a][b]='1'; } mmax=0; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if(map[i][j]=='1') { cnt=0; dfs(i,j); if(cnt>mmax) mmax=cnt; } } } printf("%d\n",mmax); } return 0;}
0 0
- poj 3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- POJ 3620 Avoid The Lakes
- POJ--3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- POJ 3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- POJ 3620 Avoid The Lakes
- poj 3620 Avoid The Lakes
- POJ 3620 Avoid The Lakes
- POJ - 3620-Avoid The Lakes
- hdoj 2544 最短路
- 异或(Exclusive-OR,Wuhan 2009,LA 4487)
- 常用meta整理,页面技术,SEO优化
- zoj1093 dp入门
- MySQL多实例管理
- poj 3620 Avoid The Lakes
- UVa 10006 - Carmichael Numbers
- poj 3159 Candies(差分约束系统)
- POJ 1456:Supermarket【贪心】
- 【Stanford CNN课程笔记】3. 梯度下降法
- c和指针程序6.2与6.3 分析
- VIM中文乱码原理详解及终极解决方案[经典]
- 线索二叉树
- 【Western Digital】固件区学习之03模块