#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 100;
int n, m;
char g[N][N];
bool st[N][N];//存狀態:淹過or沒淹過
int res = 0;
int dx[] = {1,1,1,0,0,-1,-1,-1};//八個方向
int dy[] = { -1,0,1,1,-1,1,0,-1 };
void dfs(int x, int y)
{
for (int i = 0; i < 8; i++)
{
int a = x + dx[i], b = y + dy[i];
if (a < 0 || b < 0 || a >= n || b >= m) continue;//不能越界
if (g[a][b] != 'W') continue;//旱地不走
if (st[a][b])continue;//淹過不走
st[a][b] = true;
dfs(a, b);
}
}
int main()
{
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++) scanf_s("%s", g[i]);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (g[i][j] && !st[i][j])
{
dfs(i, j);
res++;
}
}
}
printf("%d", res);
return 0;
}
Lake Counting S
相關文章
- 洛谷題單指南-搜尋-P1596 [USACO10OCT] Lake Counting S
- C++搜尋與回溯演算法之Lake Counting(數湖)C++演算法
- GCD CountingGC
- Azure Data Lake(一) 在NET Core 控制檯中操作 Data Lake Storage
- 計數排序 - Counting Sort排序
- music-lake專案梳理
- Automatic Reference Counting-SwiftSwift
- 資料湖揭祕—Delta Lake
- python ref counting based garbage collectionPython
- iOS中的Reference Counting詳解iOS
- UVa 1225 - Digit CountingGit
- 【LeetCode】Counting Bits(338)LeetCode
- LeetCode 338 Counting BitsLeetCode
- Codeforces 954H Path Counting
- projecteuler---->problem=19----Counting SundaysProject
- Digit Counting uva1225Git
- CF1919E Counting Prefixes
- Data Lake Analytics的Geospatial分析函式函式
- Delta Lake 資料湖原理和實戰
- leetcode [python] 【338】Counting BitsLeetCodePython
- LeetCode 第 338 題 (Counting Bits)LeetCode
- Python演算法:Counting 101Python演算法
- Data Lake Analytics IP白名單設定攻略
- 使用Data Lake Analytics讀/寫RDS資料
- 338. Counting Bits--LeetCode RecordLeetCode
- Databricks決定開源其Delta Lake資料湖
- 亞馬遜雲科技推出安全資料湖Amazon Security Lake亞馬遜
- 使用Data Lake Analytics從OSS清洗資料到AnalyticDB
- 資料湖倉比較:Apache Hudi、Delta Lake、Apache IcebergApache
- 為什麼Databricks Delta Lake表格式開源很重要?
- 資料湖表格式比較(Iceberg、Hudi 和 Delta Lake)
- 微軟將於明年更新Surface 或用Kaby Lake處理器微軟
- 剖析網路測量:Counting and Measuring Network Traffic
- Codeforces 372B Counting Rectangles is Fun:dp套dp
- HDU 5439 Aggregated Counting(找規律+預處理)
- 關於Delta Lake的ACID事務機制簡介
- 轉換匹配患者記錄,看Amazon Lake Formation FindMatches顯神通!ORM
- Arrow Lake系列處理器效能超越蘋果M1 Max蘋果
- HDU 5862 Counting Intersections(樹狀陣列+掃描線+離散化)陣列