7.31 D - Red and Black

                                    D - Red and Black

There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles. 

Write a program to count the number of black tiles which he can reach by repeating the moves described above. 

Input
The input consists of multiple data sets. A data set starts with a line containing two positive integers W and H; W and H are the numbers of tiles in the x- and y- directions, respectively. W and H are not more than 20. 

There are H more lines in the data set, each of which includes W characters. Each character represents the color of a tile as follows. 

'.' - a black tile 
'#' - a red tile 
'@' - a man on a black tile(appears exactly once in a data set) 
The end of the input is indicated by a line consisting of two zeros. 

Output
For each data set, your program should output a line which contains the number of tiles he can reach from the initial tile (including itself).
Sample Input
6 9
....#.
.....#
......
......
......
......
......
#@...#
.#..#.
11 9
.#.........
.#.#######.
.#.#.....#.
.#.#.###.#.
.#.#..@#.#.
.#.#####.#.
.#.......#.
.#########.
...........
11 6
..#..#..#..
..#..#..#..
..#..#..###
..#..#..#@.
..#..#..#..
..#..#..#..
7 7
..#.#..
..#.#..
###.###
...@...
###.###
..#.#..
..#.#..
0 0
Sample Output
45
59
6
13


#include<stdio.h>
#include<string.h>
char s[150][150];
int book[150][150];
int m,n,t;
int dfs(int x,int y)
{
	int i,j,k,tx,ty;
	int next[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
	
	if(x<0||y<0||x>=m||y>=n)
		return 0;	
		
	if(s[x][y]=='#')
	{
		return 0;
	}
	else
	{
		s[x][y]='#';
		return 1+dfs(x+1,y)+dfs(x-1,y)+dfs(x,y+1)+dfs(x,y-1);
	}

}
int main()
{
	int i,j,k,t,flag;
	while(scanf("%d%d",&n,&m),m+n!=0)
	{
		memset(book,0,sizeof(book));
		for(i=0;i<m;i++)
		{
			scanf("%s",s[i]);
		}
		for(i=0;i<m;i++)
		{
			for(j=0;j<n;j++)
			{
				if(s[i][j]=='@')
				{
					t=dfs(i,j);
				}
			}
		}
		printf("%d\n",t);
	}
	return 0;
}


 

内容概要:本文详细介绍了一个基于C++的养老院管理系统的设计与实现,旨在应对人口老龄化带来的管理挑战。系统通过整合住户档案、健康监测、护理计划、任务调度等核心功能,构建了从数据采集、清洗、AI风险预测到服务调度与可视化的完整技术架构。采用C++高性能服务端结合消息队列、规则引擎和机器学习模型,实现了健康状态实时监控、智能任务分配、异常告警推送等功能,并解决了多源数据整合、权限安全、老旧硬件兼容等实际问题。系统支持模块化扩展与流程自定义,提升了养老服务效率、医护协同水平和住户安全保障,同时为运营决策提供数据支持。文中还提供了关键模块的代码示例,如健康指数算法、任务调度器和日志记录组件。; 适合人群:具备C++编程基础,从事软件开发或系统设计工作1-3年的研发人员,尤其是关注智慧养老、医疗信息系统开发的技术人员。; 使用场景及目标:①学习如何在真实项目中应用C++构建高性能、可扩展的管理系统;②掌握多源数据整合、实时健康监控、任务调度与权限控制等复杂业务的技术实现方案;③了解AI模型在养老场景中的落地方式及系统架构设计思路。; 阅读建议:此资源不仅包含系统架构与模型描述,还附有核心代码片段,建议结合整体设计逻辑深入理解各模块之间的协同机制,并可通过重构或扩展代码来加深对系统工程实践的掌握。
原来的图片是<vector xmlns:android="http://schemas.android.com/apk/res/android" android:alpha="@dimen/picture3d_state_disable_alpha" android:width="@dimen/pciture3d_editor_menu_popu_tips_size" android:height="@dimen/pciture3d_editor_menu_popu_tips_size" android:viewportWidth="38" android:viewportHeight="38"> <path android:fillColor="@color/base_editor_menu_item_mask" android:pathData="M0 19c0-10.49 8.51-19 19-19h0c10.49 0 19 8.51 19 19v0c0 10.49-8.51 19-19 19h0c-10.49 0-19-8.51-19-19z"/> <path android:fillColor="#FFF" android:fillType="evenOdd" android:pathData="M19 13.19c-3.21 0-5.81 2.6-5.81 5.81c0 3.21 2.6 5.81 5.81 5.81c3.21 0 5.81-2.6 5.81-5.81c0-3.21-2.6-5.81-5.81-5.81zM11.69 19c0-4.04 3.27-7.31 7.31-7.31c4.04 0 7.31 3.27 7.31 7.31c0 4.04-3.27 7.31-7.31 7.31c-4.04 0-7.31-3.27-7.31-7.31zm7.36-2.53c-0.18-0.01-0.35 0.03-0.5 0.11c-0.16 0.08-0.3 0.2-0.38 0.36c-0.1 0.15-0.14 0.32-0.14 0.5h-1.5c0-0.45 0.12-0.89 0.35-1.27c0.23-0.39 0.56-0.7 0.95-0.91c0.4-0.21 0.85-0.31 1.3-0.29c0.44 0.02 0.87 0.17 1.25 0.41c0.37 0.25 0.67 0.6 0.86 1c0.19 0.41 0.27 0.86 0.22 1.3c-0.04 0.45-0.2 0.88-0.48 1.24c-0.26 0.35-0.62 0.63-1.02 0.8c-0.07 0.03-0.12 0.08-0.15 0.13c-0.04 0.06-0.06 0.13-0.06 0.2v0.01v0.01v0.24h-1.5v-0.23c0-0.36 0.1-0.72 0.29-1.03c0.2-0.3 0.48-0.55 0.8-0.7h0.02l0.01-0.01c0.16-0.07 0.3-0.18 0.41-0.32c0.1-0.14 0.17-0.3 0.19-0.48c0.02-0.18-0.01-0.36-0.09-0.51c-0.07-0.16-0.2-0.3-0.34-0.4c-0.14-0.1-0.32-0.15-0.5-0.16zm0.77 5.48c0 0.46-0.37 0.82-0.82 0.82c-0.45 0-0.82-0.36-0.82-0.82c0-0.45 0.37-0.82 0.82-0.82c0.45 0 0.82 0.37 0.82 0.82z"/> </vector> 我下载的svg是<svg width="45" height="45" viewBox="0 0 45 45" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect x="0.1875" y="0.693359" width="44" height="44" rx="22" fill="white" fill-opacity="0.15"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M12.8883 22.6941C12.8883 17.5579 17.052 13.3941 22.1883 13.3941C27.3245 13.3941 31.4883 17.5579 31.4883 22.是不是下错了
03-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值