POJ3620
来源:互联网 发布:淘宝店铺封面象数多少 编辑:程序博客网 时间:2024/06/05 18:01
今天开始,每天学一些数据结构和算法,然后把暑假集训的作业题都刷一遍,跳过模拟和贪心,从搜索开始。
poj3620 水题一道,dfs求连通块:
#include <cstdio>#include <cmath>#include <cstring>#include <algorithm>using namespace std;int a[200][200];int xr[]={1,0,-1,0};int yr[]={0,1,0,-1};int n,m,k;int ans=0,ret=0;void dfs(int x,int y){ if(x<1 || x>n || y<1 || y>m) return ; if(a[x][y]==0)return ; else ret++; a[x][y]=0; for(int i=0;i<4;i++){ int xx=x+xr[i]; int yy=y+yr[i]; dfs(xx,yy); }}int main(){ // freopen("in.txt","r",stdin); while(scanf("%d%d%d",&n,&m,&k)!=EOF){ memset(a,0,sizeof(a)); for(int i=1;i<=k;i++){ int x,y; scanf("%d%d",&x,&y); a[x][y]=1; } for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){ ret=0; dfs(i,j); ans=max(ans,ret); } printf("%d",ans); } return 0;}
0 0
- POJ3620
- poj3620
- POJ3620
- POJ3620
- POJ3620
- poj2386 poj3620
- poj3620 DFS
- POJ3620:Avoid The Lakes
- POJ3620 Avoid The Lakes
- Avoid The Lakes--poj3620
- 搜索入门-----POJ3620
- POJ3620 Avoid The Lakes
- 【poj3620】Avoid The Lakes
- Avoid The Lakes<poj3620>
- Avoid The Lakes(poj3620)
- DFS poj3620 Avoid The Lakes
- poj3620 avoid the lakes【dfs】
- DFS poj3620(Avoid The Lakes)
- AVCaptureDevice一些设置
- LeetCode 237 删除单链表中某一个结点
- 从头认识Spring-1.13 注入properties与null
- poj3189Steady Cow Assignment
- 程序员努力提升自己,循序渐进学编程
- POJ3620
- c++ 线程并发、任务队列、异步 任务封装和分发 lambda与任务 boost
- android-Creating Multiple APKs for Different Screen Sizes,Creating Multiple APKs for Different GL Te
- 创建一个自定义类加载器实现class文件(字节码文件)的加密解密的实例
- 成为优秀程序员的10个有效方法-要有自己的认识
- BUAA:JY的题目【水】
- 2015年终总结
- hdu--5534
- linux基础指令(一)arch