rqnoj-653
来源:互联网 发布:由诲女知之乎的意思 编辑:程序博客网 时间:2024/06/15 02:21
要一个格子能放机器人最多,可以就枚举每个格子,求每个格子能通向多少个可以放置机器人的‘R’格子。然后取最大值。
#include <stdio.h>char map[51][51];int xx[4]={0,1,0,-1};int yy[4]={1,0,-1,0};int m,n,MAX;void BFS(int x,int y){ int r[3000][2]; int h=-1,t=0,i,cnt=0; if(map[x][y]=='R') cnt++; map[x][y]='#'; r[0][0]=x; r[0][1]=y; while(h<=t) { h++; for(i=0;i<4;i++) { x=r[h][0]+xx[i]; y=r[h][1]+yy[i]; if(x>=n || x<0 || y>=m || y<0 || map[x][y]=='#')//等号忘记了 continue; if(map[x][y]=='R') cnt++; t++; r[t][0]=x; r[t][1]=y; map[x][y]='#'; } } if(cnt>MAX) MAX=cnt;}int main(){ int i,j; MAX=0; //freopen("d:\\test.txt","r",stdin); scanf("%d%d",&n,&m); for(i=0;i<n;i++) { getchar(); for(j=0;j<m;j++) scanf("%c",&map[i][j]); } for(i=0;i<n;i++) for(j=0;j<m;j++) if(map[i][j]!='#') BFS(i,j); printf("%d\n",MAX); return(0);}
'
- rqnoj-653
- rqnoj-332 & rqnoj-53
- RQNOJ 164
- RQNOJ 311
- RQNOJ 34
- 决斗 RQNOJ
- rqnoj-153
- rqnoj-394
- rqnoj-3
- rqnoj-12
- rqnoj-93
- rqnoj-4
- rqnoj-1
- rqnoj-2
- rqnoj-20
- rqnoj-15
- rqnoj-16
- rqnoj-69
- Relocations in generic ELF (EM: 40)
- [35]Search Insert Position
- Java学习笔记五
- 软件评测知识点
- 插入排序(InserSort)
- rqnoj-653
- hdu 1429 二进制 位压缩 bfs
- Using R to Fix Data Quality: Section 4
- linux 用户空间和内核空间延时函数
- 2013菏泽国际牡丹文化旅游节
- Android自动化测试之使用java调用monkeyrunner
- 构造函数的重载
- Java学习笔记六
- wAF绕过测试