POJ 3620 Avoid The Lakes
来源:互联网 发布:衣柜设计软件 编辑:程序博客网 时间:2024/05/14 11:23
//很水的dfs#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>using namespace std;const int maxn=100+10;int mx[maxn][maxn],m,n,k,cnt;int dir[4][2]= {{-1,0},{0,-1},{1,0},{0,1}}; //四个方向 int dfs(int x,int y){ int dx,dy; mx[x][y]=0;cnt++; for(int i=0; i<4; i++) //消除标记 { dx=x+dir[i][0]; dy=y+dir[i][1]; if(dx>0 && dy>0 && dx<=m && dy<=n && mx[dx][dy]==1) { //printf("%d^^^^\n",cnt); dfs(dx,dy); } } return cnt;}int main(){ while(~scanf("%d%d%d",&m,&n,&k)) { memset(mx,-1,sizeof(mx)); for(int i=0; i<k; i++) { int a,b; scanf("%d%d",&a,&b); mx[a][b]=1; //标记目标点 } int mm=1; for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) { if(mx[i][j]==1) //已标记的点 { cnt=0; dfs(i,j); if(cnt>mm) mm=cnt; //更新最大值 } } printf("%d\n",mm); } 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
- 直接插入排序
- 黑马程序员-----C语言学习之函数
- [BZOJ1010][HNOI2008]玩具装箱toy
- Activity初步认识
- 链表的基本操作
- POJ 3620 Avoid The Lakes
- 面试题06_重建二叉树——剑指offer系列
- SPFileVersion usage
- Hibernate 环境搭建
- C++基础---构造函数与析构函数
- iOS通过OTA方式分发应用的实现
- EclipseMars + Maven + SpringMVC + Tomcat7
- Java基础之流程控制
- 面试时碰到的一道数据库题目