CodeForces 616C The Labyrinth (二维并查集)

这篇博客详细介绍了如何解决CodeForces上的616C问题——The Labyrinth。文章通过一个n×m的矩阵表示迷宫,讨论了空地与障碍物相邻的概念,并定义了连通分量。任务是计算当每个障碍物变成空地时,其所属的最大连通区域的大小。博客提供了输入输出的建议和样例,并且提到了两种解题方法:一种是并查集,另一种是标记广搜。博主主要分享了并查集的代码实现。
摘要由CSDN通过智能技术生成

题目链接:http://codeforces.com/problemset/problem/616/C点击打开链接

C. The Labyrinth
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a rectangular field of n × m cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adjacent if they share a side.

Let's call a connected component any non-extendible set of cells such that any two of them are connected by the path of adjacent cells. It is a typical well-known definition of a connected component.

For each impassable cell (x, y) imagine that it is an empty cell (all other cells remain unchanged) and find the size (the number of cells) of the connected component which contains (x, y). You should do it for each impassable cell ind

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值