TYVJ 1330 乳草的入侵
来源:互联网 发布:声鉴软件 编辑:程序博客网 时间:2024/04/27 17:28
题目大意:
中文题。
解题思路:
BFS,但是这个读入太恶心了……
#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<iostream>#define LL long long#define db double#define maxn 10000000#define max(a,b) ((a>b)?(a):(b))#define min(a,b) ((a<b)?(a):(b))using namespace std;int n,m,bx,by;bool mp[101][101];int xx[8]={1,-1,1,-1,0,0,1,-1},yy[8]={1,-1,-1,1,1,-1,0,0};struct data{int x,y,step;}q[10001];bool judge(int x,int y){if (mp[x][y]||x<1||y<1||x>m||y>n) return 0;mp[x][y]=1;return 1;}int bfs(int bx,int by){int t=0,w=1;int nowx,nowy;q[0].x=bx; q[0].y=by;mp[bx][by]=1;while (t<w){for (int i=0;i<8;i++){nowx=q[t].x+xx[i];nowy=q[t].y+yy[i];if (judge(nowx,nowy)){q[w].x=nowx;q[w].y=nowy;q[w].step=q[t].step+1;w++;}}t++;}printf("%d",q[w-1].step);}int main(){scanf("%d%d%d%d",&n,&m,&bx,&by);char ch[101];for (int i=m;i>0;i--){scanf("%s",ch);for (int j=0;j<n;j++)if (ch[j]=='*') mp[i][j+1]=1;}bfs(bx,by);return 0;}
0 0
- TYVJ 1330 乳草的入侵
- tyvj 乳草的入侵
- tyvj p1030 乳草的入侵
- |Tyvj|BFS|P1030 乳草的入侵
- 【BFS】Tyvj P1030 乳草的入侵
- 【tyvj】1030 乳草的入侵 bfs
- Tyvj P1030 乳草的入侵
- TYVJ-1030 如草的入侵 FLOOD FILL
- 乳草的入侵
- 乳草的入侵
- 乳草的入侵
- 【tyvj1030】乳草的入侵
- C语言BFS(1)___乳草的入侵
- TYVJ
- 黑客入侵的基础:口令入侵法
- 3406: [Usaco2009 Oct]Invasion of the Milkweed 乳草的入侵
- bzoj 3406: [Usaco2009 Oct]Invasion of the Milkweed 乳草的入侵
- bzoj3406 [Usaco2009 Oct]Invasion of the Milkweed 乳草的入侵
- Linux学习笔记:系统启动引导过程
- leetcode 130: Surrounded Regions
- ListView的工作原理及优化
- Unity_角色控制详解
- Oracle清理回收站的方法
- TYVJ 1330 乳草的入侵
- /sys/class/gpio 文件接口操作IO端口(s3c2440)
- CSS3属性box-flex
- hdoj5253
- OC_Notifications(通知)
- IO流笔记02
- 从零开始学习iOS开发-股票记帐本1.0(1)
- 【CF 474E】Pillars
- Practice Round APAC test Problem A. Bad Horse 2-sat